问题
I'm using cURL with PHP and getting the following error after sometime (I guess after 300 sec):
Fatal error: Maximum execution time of 500 seconds exceeded.
I googled this and found some solutions that are also not working for me, such as:
ini_set('MAX_EXECUTION_TIME', -1);
error_reporting(1); // to display only fatal error
set_time_limit(0);
I've tried both MAX_EXECUTION_TIME
and MAX_INPUT_TIME
and set them to -1
but nothing is helping me.
Update
I've used this as well:
ignore_user_abort(true);
ini_set('MAX_EXECUTION_TIME', 0);
error_reporting(1);
set_time_limit(0);
and inside cURL
curl_setopt($s, CURLOPT_TIMEOUT, 0);
but it is still giving me the following error:
Fatal error: Maximum execution time of 500 seconds exceeded in D:\wamp\www\optimized.php on line 321
回答1:
set it too 300 which is approx 300 secs = 5 minutes
ini_set('MAX_EXECUTION_TIME', 300);
if you set it to 0 , which mean no limits.
ini_set('MAX_EXECUTION_TIME', 0);
for cURL you can use this one
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
here again 0 means infinite...
回答2:
As you are using curl, make the curl's timeout infinite
using 0
curl_setopt($ch, CURLOPT_TIMEOUT, 0); // or provide number of seconds!
回答3:
I change :
default_socket_timeout=1200
on php.ini
It worked for me.
来源:https://stackoverflow.com/questions/22421876/fatal-error-maximum-execution-time-of-500-seconds-exceeded