Home >Backend Development >PHP Tutorial >Three ways to set the maximum execution time of a script in PHP

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

藏色散人
藏色散人forward
2020-06-13 13:53:403797browse

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

The default maximum execution time in php.ini is 30 seconds, which is determined by the max_execution_time variable in php.ini Specify, if the script needs to run for a long time;

In this case, the maximum execution time of the php script must be changed.

1. Set in php.ini

max_execution_time = 120;

2. Set through PHP’s ini_set function

ini_set("max_execution_time", "120");

3. Set through set_time_limit function

set_time_limit(120);

Method one is mainly applicable when the website has been completed and the post-maintenance personnel are not familiar with the code structure. Methods two and three are suitable when writing code. However, method two is not recommended because you need to pay attention to whether the ini_set function will be used. Disabled.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of Three ways 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:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete