php 使用 ini_set('max_execution_time', 0);
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6523164/
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
On using ini_set('max_execution_time', 0);
提问by Nyxynyx
How do I use ini_set('max_execution_time', 0);
?
我如何使用ini_set('max_execution_time', 0);
?
Question 1:Do I place it at the top of the .PHP file or in a function that takes a long time to do something?
问题 1:我是将它放在 .PHP 文件的顶部还是放在需要很长时间才能做某事的函数中?
Question 2:Does this setting last forever after being set? Or does it return back to its original 300sec or whatever default value after the function stops running?
问题二:此设置设置后是否永久有效?或者它会在函数停止运行后恢复到原来的 300 秒或任何默认值?
回答by Brad
You can place it anywhere, but that setting won't take effect until it runs. So if you put it at the top, then the script will never timeout. If you put it down below on the function that can take awhile, then you may get a timeout above if the script takes a long time to get to where you called it.
您可以将它放在任何地方,但该设置在它运行之前不会生效。所以如果你把它放在顶部,那么脚本永远不会超时。如果你把它放在可能需要一段时间的函数下面,那么如果脚本需要很长时间才能到达你调用它的地方,你可能会在上面得到超时。
When you use ini_set()
that option stays in effect for the entire execution of the script.
当您使用ini_set()
该选项时,该选项将在脚本的整个执行过程中保持有效。
回答by Naftali aka Neal
2: It only last for that page that loaded. after that its done.
2:它只持续加载的那个页面。之后就完成了。
1: It should be placed at the start of the code, but it can be placed anywhere.
1:应该放在代码的开头,但可以放在任何地方。
回答by cweiske
Answer 1: before you execute the long-running code
答案 1:在执行长时间运行的代码之前
Answer 2: it lasts until the php process ends
答案2:一直持续到php进程结束