I am using curl to request another site for getting data. My code having curl_reset()
funciton is working well at localhost, but when i have updated my code to
PHP is old on your server.
From the manual: (PHP 5 >= 5.5.0)
My PHP version is 5.3 so i was not able to use curl_reset()
function.
I was using curl_reset()
function for getting response of multiple curl request.
So i have removed curl_reset()
and used
curl_setopt($curl_handle, CURLOPT_HTTPGET, 1);
curl_setopt($curl_handle, CURLOPT_POST, false);
Problem was after post request my get request was not giving response when i have set curl_post to false to my request it works well.
Conclusion: Its important keep calling setopt to switch between GET and POST request when you are using multiple curl request.
Here is the solution tested 100% working:
Error from php-error-log due to using curl_reset with php version 5.4:
Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset() in ...
Upgrade to php version 5.5 successfully resolved issue. If you are on cpanel upgrading php version takes only 3 or 4 clicks.
enjoy!
Please mark as answered if it resolve the issue. Thanks!
Requires no PHP version updating.
if (!function_exists('curl_reset'))
{
function curl_reset(&$ch)
{
$ch = curl_init();
}
}