Hi all I need help regarding cURL, I'm new to using cURL in PHP so I want to ask this.
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $get_url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$variable = curl_exec($curl);
$variable's value is boolean while cURL echoes a string during execution. Is there anyway I could get that echoed string pass to a variable?
Thanks in advance
Set the option curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
to return the result as a string, in your case the string will be stored in $variable
. Then, pass $variable
to whatever function you desire.
Another solution is this way:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $get_url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
ob_start();
curl_exec($curl);
$variable = ob_get_clean();