ini_set, set_time_limit, (max_execution_time) - not working

心已入冬 提交于 2019-12-17 07:48:08

问题


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 30 and completely ignores my request. Why is this?


回答1:


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.

-- PHP manual, Runtime Configuration, description of 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:

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 manual, set_time_limit page




回答2:


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.

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




回答3:


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



来源:https://stackoverflow.com/questions/1590441/ini-set-set-time-limit-max-execution-time-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!