我从一个在线源下载一个JSON文件,当它通过循环运行时,我得到这个错误:

致命错误:C:\wamp\www\temp\fetch.php第24行超过最大执行时间30秒


当前回答

我有同样的问题,并通过改变参数max_execution_time在php.ini中的值来解决它,就像这样:

max_execution_time = 360      ; Maximum execution time of each script, in seconds (I CHANGED THIS VALUE)
max_input_time = 120          ; Maximum amount of time each script may spend parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 128M           ; Maximum amount of memory a script may consume (128MB by default)

我希望这能帮助到你。

其他回答

编辑php . ini

找到这条线:

max_execution_time

将其值改为300:

max_execution_time = 300

300表示HTTP请求的执行时间为5分钟。

你的循环可能是无止境的。如果不是,你可以像这样延长最大执行时间:

ini_set('max_execution_time', '300'); //300 seconds = 5 minutes

and

set_time_limit(300);

可用于临时延长时间限制。

也许可以检查php.ini文件下更改的任何内容。 例如,我将“;Intl .default_locale =”更改为“;Intl .default_locale = en_utf8”,以便启用“国际化扩展(Intl)”而不添加“extension=php_intl.dll”,然后出现相同的错误。所以我建议检查类似的错误。

您的脚本超时了。看一下set_time_limit()函数来延长执行时间。或者分析脚本,使其运行得更快:)

我们可以用三种不同的方法来解决这个问题。

1)使用php.ini文件

2)使用。htaccess文件

3)使用Wp-config.php文件(Wordpress)