您的位置:首页 > 编程语言 > PHP开发

php自动刷新与关闭页面后继续执行,定时任务的实现方式

2017-10-27 10:54 671 查看
<?
ignore_user_abort(true);
set_time_limit(0);
while(1){
$myfile = fopen("newfile.txt", "a+") or die("Unable to open file!");  //w  重写  a追加
$txt = date("Y-m-d h:i:s")."\n\r";
fwrite($myfile, $txt);
fclose($myfile);
//echo "5"."<br>";
sleep(5); //5秒执行一次
//echo "5"."<br>";
}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: