实现定时器文件 Timer.php
ignore_user_abort();//关闭浏览器后,继续执行php代码
set_time_limit(0);//程序执行时间无限制
$sleep_time = 5;//多长时间执行一次
$switch = include 'switch.php';
while($switch){
$switch = include 'switch.php';
$fp = fopen('test.txt','a+');
$time = time();
$string ="这是一个php博客:phpddt.com $time \n";
fwrite($fp,$string);
fclose($fp);
sleep($sleep_time);
}
exit();
控制定时器结束文件switch.php
return true;
执行php Timer.php &即可
浙公网安备 33010602011771号