Home > php教程 > php手册 > body text

PHP自动执行代码,大家来评论下

WBOY
Release: 2016-06-07 11:37:51
Original
1465 people have browsed it

自动执行代码
<?php <br /> ignore_user_abort();<br> //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行.<br> set_time_limit(0);<br> $interval=60*5;<br> do{<br> $fp= fopen("test.txt","a");<br> fwrite($fp,"rn".date('Y-m-d H:i:s',time())."rn");<br> fclose($fp);<br> sleep($interval);<br> }while(true);<br> echo'ok';<br> ?>用上诉代码,是可以实现正常的 自动执行。
但这样做会对服务器有一定的负荷吗?
相比计划任务、跟cron 来说!

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!