php ini_set, set_time_limit, (max_execution_time) - 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1590441/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:12:13  来源:igfitidea点击:

ini_set, set_time_limit, (max_execution_time) - not working

phpmysqlconnection

提问by Mickey

If I do set_time_limit(50)or ini_set('max_execution_time',50), then when I echo ini_get('max_execution_time')on my localhost i get 50, but when I do this on another server it echoes the default 30and completely ignores my request. Why is this?

如果我这样做set_time_limit(50)ini_set('max_execution_time',50),那么当我ini_get('max_execution_time')在我的本地主机上回显时,我得到50,但是当我在另一台服务器上执行此操作时,它会回显默认值30并完全忽略我的请求。为什么是这样?

采纳答案by Powerlord

You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini.

在安全模式下运行时,您无法使用 ini_set() 更改此设置。唯一的解决方法是关闭安全模式或更改 php.ini 中的时间限制。

-- PHP manual, Runtime Configuration, description of max_execution_time

-- PHP 手册,运行时配置,描述max_execution_time

Many hosts run in safe mode. The other server is most likely one of them.

许多主机在安全模式下运行。另一台服务器很可能是其中之一。

Edit: The same restriction is in place on set_time_limit:

编辑:同样的限制适用于set_time_limit

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 中的时间限制外,没有其他解决方法。

-- PHP manual, set_time_limitpage

-- PHP 手册,set_time_limit页面

回答by Rahul

You can change max_execution_time.
Upload a 1 line (max_execution_time = 600) php5.inito your root folder (where php.ini resides).

您可以更改 max_execution_time。
将 1 行 (max_execution_time = 600) php5.ini 上传到您的根文件夹(php.ini 所在的位置)。

回答by Alex Mcp

Does GoDaddy allow you to edit their remote PHP.INI file, or (achieving the same function) set those options at runtime? Many restrictive hosts (and I don't know this about GoDaddy one way or the other) won't let you futz with PHP options either via the config file or at runtime as you did on WAMP. It could be that though you're still calling that function, it's not being applied.

GoDaddy 是否允许您编辑他们的远程 PHP.INI 文件,或者(实现相同的功能)在运行时设置这些选项?许多限制性主机(我不知道 GoDaddy 的这种或另一种方式)不会让您通过配置文件或在运行时使用 PHP 选项,就像您在 WAMP 上所做的那样。可能是虽然您仍在调用该函数,但它并未被应用。

Use

echo 'Time Limit = ' . ini_get('max_execution_time') .

The manual says that if it's set at all in the PHP.INI, that will override this runtime. PHP Manual on set_time_limit

手册说,如果在 PHP.INI 中设置了它,它将覆盖此运行时。 关于 set_time_limit 的 PHP 手册