PHP Time Limit Functions Ineffective on Remote Server
When setting time limits using set_time_limit(50) or ini_set('max_execution_time', 50) locally, retrieving max_execution_time yields the desired value. However, on a different server, it reverts to the default value (30 seconds), rendering these functions ineffective.
Explanation
The issue arises due to the safe mode setting on the remote server. In PHP's safe mode, it is not possible to modify the max_execution_time setting using ini_set(). This restriction also applies to set_time_limit().
Workaround
To resolve this issue, there are two options:
Reason for Safe Mode Restriction
Safe mode was introduced in PHP to enhance security by limiting certain actions that could be performed by scripts. Preventing scripts from running indefinitely is one of these security measures.
Note: The PHP manual clearly states that both set_time_limit() and ini_set('max_execution_time', 50) have no effect when safe mode is enabled. The only workaround is to disable safe mode or adjust the time limit in the php.ini file.
The above is the detailed content of Why are `set_time_limit` and `ini_set(\'max_execution_time\')` ineffective on my remote server with safe mode enabled?. For more information, please follow other related articles on the PHP Chinese website!