How to set the page running time in php: 1. Open the php.ini configuration file; 2. Find the max_execution_time variable; 3. Modify the page running time.
The operating environment of this article: windows10 system, php 7.1, thinkpad t480 computer.
We all know that by default, the maximum execution time configured in php.ini is 30 seconds, which is specified by the max_execution_time variable in php.ini. So if we have a job that takes a lot of time, such as sending a large number of emails, or performing a huge statistical analysis of data, the server will forcibly terminate the executing program after 30 seconds even if the task is not completed. . It is conceivable that we are very unwilling to see this situation, so can we set the page execution time? The answer is yes.
Let’s take a look at the specific methods.
1, two methods to modify the maximum execution time
(1) Directly modify the value of max_execution_time in php.ini.
(2) If you do not have permission to modify the php.ini file, or we want to set up individual pages for some pages. Then you can also set it in the PHP program page, the code is as follows (a value of 0 means there is no execution time limit).
ini_set('max_execution_time', '0')
Recommended learning: php training
The above is the detailed content of How to set page running time in php. For more information, please follow other related articles on the PHP Chinese website!