Home  >  Article  >  Backend Development  >  set_time_limit — Set the maximum script execution time

set_time_limit — Set the maximum script execution time

PHP中文网
PHP中文网Original
2017-03-21 15:02:541979browse

(PHP 4, PHP 5)

set_time_limitSet the maximum execution time of the script

Instructions

void set_time_limit ( int $seconds )

Set the time the script is allowed to run, in seconds. If this setting is exceeded, the script returns a fatal error. The default value is 30 seconds, or the value defined in max_execution_time, if this value exists.

When this function is called, set_time_limit() will restart the timeout counter from zero. In other words, if the default timeout is 30 seconds, and 25 seconds are set in the script, such as set_time_limit(20). Then, the script can run for a total of 45 seconds before timing out.

Parameters

  • seconds

  • Maximum execution time , the unit is seconds. If set to 0 (zero), there is no time limit.

Return value

No return value.

Note

Note:

set_time_limit()The function and configuration directive max_execution_time only affect the execution time of the script itself. The maximum time for any script execution that occurs such as system calls using system(), stream operations, database operations, etc. is not included when the script is already running. In Windows, where measured times are real-valued, this is not the case.

Related articles:

php page maximum execution time set_time_limit function does not work

php set_time_limit() sets page execution Time

php set_time_limit(0) Function to set program execution time

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