Home >Backend Development >PHP Problem >How to modify the maximum time in php
Methods to modify the maximum time in php: 1. Set "max_execution_time = 120;" in php.ini; 2. Set it through PHP's ini_set function; 3. Set it through the set_time_limit function.
#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
How to modify the maximum time in php?
Three methods for PHP to set the maximum execution time of a script
The default maximum execution time in php.ini is 30 seconds, which is determined by php The max_execution_time variable in .ini specifies that if the script needs to run for a long time, such as sending a large number of emails, or analyzing a large amount of data, the server will forcibly terminate the executing program after 30 seconds. In this case, the PHP script must be changed. Maximum execution time.
Three ways to set the maximum execution time of a script in PHP
1. Set it in php.ini
max_execution_time = 120;
2. Set it through PHP's ini_set function
ini_set("max_execution_time", "120");
3. Set through the set_time_limit function
set_time_limit(120);
If the above numbers are set to 0, there will be no limit, and the script will continue to execute until the end of execution.
Therefore, for scripts that need to be executed for a long time, generally add the following code at the beginning of the PHP code
set_time_limit(0);
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to modify the maximum time in php. For more information, please follow other related articles on the PHP Chinese website!