Home  >  Article  >  Backend Development  >  What is the method to set the maximum execution time of a script in php

What is the method to set the maximum execution time of a script in php

王林
王林Original
2020-11-09 17:50:042128browse

The method for php to set the maximum execution time of a script is: first open the php.ini configuration file; then modify the configuration [max_execution_time = 120;]. We can also complete the setting by adding [set_time_limit(0);] to the script.

What is the method to set the maximum execution time of a script in php

Three ways to set the maximum execution time of a script in PHP:

(Learning video recommendation: java video tutorial)

1. Modify the php.ini configuration file

max_execution_time = 120;

2. Set it through PHP’s ini_set function

ini_set("max_execution_time", "120");

3. Set it through the set_time_limit function

set_time_limit(120);

or above If several numbers are set to 0, there will be no limit, and the script will continue to execute until the end of execution.

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);

Related recommendations: php training

The above is the detailed content of What is the method 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