Home  >  Article  >  Backend Development  >  Why doesn't php limit execution time?

Why doesn't php limit execution time?

青灯夜游
青灯夜游Original
2021-09-18 16:33:094081browse

In PHP, you can use the set_time_limit() function to limit the execution time. This function can set the maximum execution time of the script file. When the parameter value is set to 0, the script can be executed without limit; syntax " set_time_limit(0)".

Why doesn't php limit execution time?

The operating environment of this tutorial: Windows 7 system, PHP version 7.1, DELL G3 computer

In PHP, you can use the set_time_limit() function There is no limit on execution time. Just set the following code:

set_time_limit(0);

set_time_limit - Set the maximum execution time of the script, The unit is 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 in php.ini, 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 set_time_limit(20) is called when the script has been running for 25 seconds, then the total time the script can run before timing out is 45 seconds.

If you set the parameter value of the set_time_limit() function to 0 (zero), there is no time limit and the program can be executed without limit.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Why doesn't php limit execution time?. 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