PHP does not detect whether a user has been disconnected until an attempt is made to send a message to the client. Simply use the ECHO statement to not ensure that information is sent, see the flush () function.
| The code is as follows |
Copy Code |
Ignore_user_abort (TRUE); Set_time_limit (0);
while (1) { $fp = fopen (' Time_task.txt ', "A +"); $STR = Date ("y-m-d h:i:s"). " NR "; Fwrite ($fp, $STR); Fclose ($FP); Sleep (5); Execute once in half an hour } ?> |
Definition and usage
The Ignore_user_abort () function sets the execution of the script to terminate if the client disconnects.
This function returns the previous value of the User-abort setting (a Boolean value).
Grammar
Ignore_user_abort (setting) parameter description
setting is optional. If set to true, disconnecting from the user is ignored and setting to false causes the script to stop running.
If this parameter is not set, the current setting is returned.
Hints and Notes
Note: PHP does not detect whether a user has been disconnected until an attempt is made to send a message to the client. Simply use the ECHO statement to not ensure that information is sent, see the flush () function.
Here is an article you can refer to
Http://www.bkjia.com/phper/php/php-ignore_user_abort.htm
http://www.bkjia.com/PHPjc/444703.html www.bkjia.com true http://www.bkjia.com/PHPjc/444703.html techarticle PHP does not detect whether a user has been disconnected until an attempt is made to send a message to the client. Simply use the ECHO statement to not ensure that information is sent, see the flush () function. The code is as follows ...