During the previous work, I encountered a PHP function: set_time_limit(). I originally thought this was a very simple function, but after reading several articles on Baidu, I found that there are many aspects that need to be paid attention to when using this function.
First of all, the set_time_limit() function is used to control the running time of the PHP page. When a certain PHP page in our program has a large amount of data, we need to use this function, such as looping a certain program a million times or When reading large amounts of data from the database.
set_time_limit() accepts an integer parameter, which represents the maximum execution time of the page, and the time is in seconds. The default execution time is 30 seconds. When the seconds is set to 0, it means continuous running for a long time. Such as:
set_time_limit(300)—Indicates that the maximum execution time of the page is 300 seconds.
set_time_limit(0)——Indicates that the page will continue to run.
The above is the basic usage of the set_time_limit() function. This function is also very simple to use, but you need to pay attention to the following points when using this function, otherwise the function may not work or be used improperly.
1. When using this function, you need to turn off the safe mode of PHP, that is, you need to change the value of safe_mode in the PHP configuration file
Set to off.
2. This function is the same as the max_execution_time option in the PHP configuration file, and is used to control the execution time of the page.
3. According to the explanation of this function in the PHP manual, when this function is called, the program's timeout counter will be reset to 0, which means that the execution time of the page will be calculated from 0. For example, the default maximum execution time of the page is 30 seconds, but when the page is executed for 20 seconds, the function set_time_limit(30) is called, then the maximum execution time of the page becomes (20+30)=50 seconds. In other words, the maximum execution time of the page = the time the current script has been executed + the time set by the set_time_limit() function.
http://www.bkjia.com/PHPjc/621605.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621605.htmlTechArticleDuring the previous work, I encountered a PHP function: set_time_limit(). I originally thought this was a very simple function, but after reading a few articles on Baidu, I found that when using this function...