Home >Database >Mysql Tutorial >Why are `ini_set(\'max_execution_time\')` and `set_time_limit()` ineffective on a server but work on localhost?

Why are `ini_set(\'max_execution_time\')` and `set_time_limit()` ineffective on a server but work on localhost?

Patricia Arquette
Patricia ArquetteOriginal
2024-11-01 05:06:27412browse

Why are `ini_set('max_execution_time')` and `set_time_limit()` ineffective on a server but work on localhost?

ini_set, set_time_limit, and (max_execution_time) Not Functioning

Question:

Why do set_time_limit() and ini_set('max_execution_time') function correctly on a localhost but fail on another server?

Answer:

The inability to adjust execution time using these functions stems from the PHP runtime configuration setting, max_execution_time, being prohibited from modification via ini_set() when safe mode is enabled.

Explanation:

Many web hosts employ safe mode, a security measure that restricts certain PHP functions. When running in safe mode, attempts to alter max_execution_time using ini_set() are ignored.

The solution to this issue is either to disable safe mode or change the time limit in the php.ini configuration file. Additionally, set_time_limit() is also affected by this restriction in safe mode, with no workaround available.

The above is the detailed content of Why are `ini_set(\'max_execution_time\')` and `set_time_limit()` ineffective on a server but work on localhost?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn