Scheduled Tasks
Copy CodeThe code is as follows:
Ignore_user_abort (); User Close Browser program still executes
Set_time_limit (0); No limit on program run time
$interval = 3; Program Cycle time interval seconds
$link = mysql_connect (' localhost ', ' username ', ' paswd ');
mysql_select_db (' Test ');
mysql_query ("SET NAMES ' UTF8 '");
do {
User closes browser stop start
Echo str_repeat (', 4069); PHP only checks the user connection status when it is output. Some Web servers have a output_buffering default value of 4096 characters. To ensure that flush () is valid, set to 4069.
Ob_flush ();
Flush ();
User closes browser stop end
$query = "INSERT into ' test '. ' Test_demo ' (' title ', ' content ') VALUES (' Scheduled task ', '". Date ("Y-m-d h:i:s", Time ()). "')";
mysql_query ($query); Use Write Database Validator
Sleep ($interval);
} while (true);
If there is no output PHP is unable to detect the user connection status. Even if you close the browser the program will still run until the Apache service stops or restarts.
Copy CodeThe code is as follows:
User closes browser stop start
Echo str_repeat (', 4069); PHP only checks the user connection status when it is output. Some Web servers have a output_buffering default value of 4096 characters. To ensure that flush () is valid, set to 4069.
Ob_flush ();
Flush ();
User closes browser stop end
http://www.bkjia.com/PHPjc/325193.html www.bkjia.com true http://www.bkjia.com/PHPjc/325193.html techarticle The Plan task copy code code is as follows: Ignore_user_abort ();//user Close browser program still executes set_time_limit (0);//No Limit program run time $interval = 3;//program Loop ...