Home > Database > Mysql Tutorial > body text

Why are `set_time_limit` and `ini_set(\'max_execution_time\')` ineffective on my remote server with safe mode enabled?

DDD
Release: 2024-10-31 09:45:02
Original
714 people have browsed it

Why are `set_time_limit` and `ini_set('max_execution_time')` ineffective on my remote server with safe mode enabled?

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:

  1. Disable Safe Mode: This can be done by modifying the server's configuration. However, it is generally not recommended due to security concerns.
  2. Modify php.ini: Edit the php.ini file on the remote server and set max_execution_time to the desired value.

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template