PHP method to execute code at intervals, php interval
The example in this article describes how PHP executes code at intervals. Share it with everyone for your reference. The specific analysis is as follows:
How to set up PHP to automatically execute a certain piece of code every once in a while? For example, to generate static files regularly, you need to set the sleep time, that is, the program will call a certain piece of code every once in a while.
The code is as follows:
Copy code The code is as follows:
ignore_user_abort(); //Even if the Client is disconnected (such as closing the browser), the PHP script can continue to execute .
set_time_limit(0); // The execution time is unlimited. The default execution time of PHP is 30 seconds, which allows the program to execute without limit
$interval=24*60*60; // Run every other day
do{
sleep($interval); // Wait one hour for loop execution according to the set time
$sql="update blog set time=now()";
...... //Other operations
}while(true);
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/920613.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/920613.htmlTechArticleHow PHP executes code at intervals, php interval This article describes how PHP executes code at intervals. Share it with everyone for your reference. The specific analysis is as follows: PHP such as...