_php Tutorial on Ignore_user_abort function Implementation of PHP scheduled tasks

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.