Home  >  Article  >  Backend Development  >  How to cancel time limit in php

How to cancel time limit in php

王林
王林Original
2021-07-07 14:41:162701browse

The way to cancel the time limit in php is to add the set_time_limit function in the php script and set the parameter to 0, such as [set_time_limit(0);]. The set_time_limit function is used to set the time allowed for the script to run.

How to cancel time limit in php

The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.

In PHP, you can use the set_time_limit function to set the time (in seconds) that the script is allowed to run. 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.

Cancel time limit:

set_time_limit(0);

Note:

The set_time_limit() function and the 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 video tutorials: php video tutorial

The above is the detailed content of How to cancel time limit in php. 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