Home >Backend Development >PHP Problem >How to set the maximum execution time of a script in php

How to set the maximum execution time of a script in php

王林
王林Original
2020-08-04 15:24:113863browse

How to set the maximum execution time of a script in php: first open the php.ini configuration file; then find the max_execution_time configuration; and finally set the value of the configuration to 120. If the script needs to be executed for a long time, just add the code [set_time_limit(0)] at the beginning of the file.

How to set the maximum execution time of a script in php

#Three methods for PHP to set the maximum execution time of a script.

(Recommended tutorial: php graphic tutorial)

1. Set in php.ini

max_execution_time = 120;

2. Set through PHP's ini_set function

ini_set("max_execution_time", "120");

(Video tutorial recommendation: php video tutorial)

3. Set the above numbers through the set_time_limit function

set_time_limit(120);

If the above numbers are set to 0, there will be no Limit, the script will continue to execute until the execution ends.

So, for scripts that need to be executed for a long time, generally just add the following code at the beginning of the php code.

set_time_limit(0);

The above is the detailed content of How to set the maximum execution time of a script 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