Remember this function:
Function name:ignore_user_abort
Whether the PHP program continues to execute after this function has been configured or if the use End connection is interrupted. The default value stops when the connection is interrupted. The Ignore_user_abort option in the PHP configuration file (Php3.ini/php.ini) is the configuration section.
How to use:
The code is as follows:
Ignore_user_abort (true//
This will enable you to achieve your scheduled tasks. However, the client access program is still the only line.
For example, in the generation of static pages, collection, there is no need to wait. Turn off your browser.
Example:
The code is as follows:
// Test Set_time_limit (0); Ignore_user_abort (true); $i = 0 ; while ($i + <) {file_put_contents($i$i); Sleep (3
using the Ignore_user_abort function to implement PHP planning tasks
Set_time_limit (0) The maximum execution time, in seconds. If set to 0 (0), there is no time limit.
The code is as follows:
<?PHPIgnore_user_abort(true);Set_time_limit(0);// while(1) {$fp=fopen(' Time_task.txt ', "A +"); $str=Date("Y-m-d h:i:s"). " \n\r "; fwrite($fp,$str); fclose($fp); Sleep(5);//execute once in half an hour}?>
A function that PHP will continue to execute after it has been scheduled to close the browser ignore_user_abort