This is a slightly more literal answer to the question. That is, the curl will still stop after 30 seconds, but you can catch the error and keep going if you want.
ini_set('max_execution_time', 40); // prevents 30 seconds from being fatal $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 30); // curl timeout remains at 30 seconds curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); curl_exec($ch); if ($error_number = curl_errno($ch)) { if (in_array($error_number, array(CURLE_OPERATION_TIMEDOUT, CURLE_OPERATION_TIMEOUTED))) { print "curl timed out"; } } curl_close($ch);
If you do not have control over max_execution_time, you can slightly reduce the waiting time for curls.
cesoid
source share