php 如何增加php中的最大执行时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16171132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to increase maximum execution time in php
提问by Sanjay Developer
I want to increase maximum execution timein php , not by changing php.ini
file.
我想增加php 的最大执行时间,而不是通过更改php.ini
文件。
I want to Increase it from my php file.
我想从我的 php 文件中增加它。
Is this possible?
这可能吗?
回答by James Scholes
ini_set('max_execution_time', '300'); //300 seconds = 5 minutes
ini_set('max_execution_time', '0'); // for infinite time of execution
Place this at the top of your PHP script and let your script loose!
把它放在你的 PHP 脚本的顶部,让你的脚本松散!
Taken from Increase PHP Script Execution Time Limit Using ini_set()
回答by Amir
use below statement if safe_mode
is off
如果safe_mode
关闭,请使用以下语句
set_time_limit(0);
回答by TheEwook
Use the PHP function
使用 PHP 函数
void set_time_limit ( int $seconds )
The maximum execution time, in seconds. If set to zero, no time limit is imposed.
最大执行时间,以秒为单位。如果设置为零,则没有时间限制。
This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.
当 PHP 在安全模式下运行时,此功能无效。除了关闭安全模式或更改 php.ini 中的时间限制外,没有其他解决方法。
回答by Adam Wright
You can try to set_time_limit(n)
. However, if your PHP setup is running in safe mode, you can onlychange it from the php.ini
file.
你可以试试set_time_limit(n)
。但是,如果您的 PHP 设置在安全模式下运行,则只能从php.ini
文件中更改它。