How to get the PHP program to perform automatically (backstage) ____php

Source: Internet
Author: User
How to get the PHP program to execute automatically, this requires a function:


int Ignore_user_abort ([bool setting])
Definitions and usage
The Ignore_user_abort () function setting terminates the execution of the script if it disconnects from the client.
This function returns the previous value (a Boolean value) of the User-abort setting.


Note: PHP does not detect if the user is disconnected until an attempt is made to send the message to the client.
Simply using the Echo statement cannot ensure that information is sent, see the flush () function.


This example, after the user closes the browser, the script continues to execute on the server:


<?php
Ignore_user_abort (); Background run
Set_time_limit (0); Timeout limit for canceling script run time
$interval =60*30;//run every half hour, this interval can be modified as needed
do{
XXXXX//Here is the code you want to execute
Sleep ($interval); Dormant for half an hour
}while (TRUE);
?>

This enables the automatic execution of the program in the background.

Reference:
Http://www.cnblogs.com/zdz8207/p/3765567.html

Http://blog.sina.com.cn/s/blog_8de9ddff010145ss.html





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.