ignore_user_abort实现计划任务
添加评论
2009年11月24日
ignore_user_abort,这个函数可以帮助我们实现像linux中的cron一样实现计划任务,用户关掉浏览器后还可以执行。
使用方法:先使用函数set_time_limit(0)设置程序的执行时间为无限制。
例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <?php // Ignore user aborts and allow the script // to run forever ignore_user_abort(true); set_time_limit(0); echo 'Testing connection handling in PHP'; // Run a pointless loop that sometime // hopefully will make us click away from // page or click the "Stop" button. while(1) { // Did the connection fail? if(connection_status() != CONNECTION_NORMAL) { break; } // Sleep for 10 seconds sleep(10); } // If this is reached, then the 'break' // was triggered from inside the while loop // So here we can log, or perform any other tasks // we need without actually being dependent on the // browser. ?> |
原来php下也有这项功能
PHP的功能真是很强大,比起Asp真是厉害很多!
哈哈,php只有想不到
php的执行速度也算是略胜一筹吧
其实我更想了解,当我希望修改时间间隔,甚至停止这个任务要如何操作?
Ps:感觉当做研究可以,实际要用计划任务还是要系统来做~~
@东莞SEO
ASP呀,微软自己都淘汰了,主推asp.net,现在google下aspx,还是比php数量少很多