<?php
ob_start();
set_time_limit(0);
//run in background
ignore_user_abort(TRUE);
/* close browser connection */
$size = ob_get_length();
header("Connection: close");
header("Content-Length: $size");
ob_end_flush();
flush();
/**
* main
*/
//your code
?>
ob_start();
set_time_limit(0);
//run in background
ignore_user_abort(TRUE);
/* close browser connection */
$size = ob_get_length();
header("Connection: close");
header("Content-Length: $size");
ob_end_flush();
flush();
/**
* main
*/
//your code
?>
上面的程序只要客户端浏览器http请求即可触发,然后便主动断开浏览器连接,以后台方式继续运行。可以用在触发执行任务的场合。非常有用!
没有评论:
发表评论