php shell_exec实时更新 [英] php shell_exec with realtime updating
本文介绍了php shell_exec实时更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个要通过php执行的shell程序.问题在于,这可能需要很长时间,因此,我需要对用户的浏览器进行实时更新.
I have this shell program that I want to execute by php. The problem is that it can potentially take a long time, and as of that I need it to have real-time updating to the user's browser.
我读到我可能需要使用popen()来做到这一点,但是我有点(好吧,我的确是:P)一个PHP noob,无法弄清楚如何做到这一点.
I read that I may need to use popen() to do that, but I am sort of (ok, I really am :P) a PHP noob and can't figure out how I may be able to do it.
非常感谢您的帮助!
推荐答案
if( ($fp = popen("your command", "r")) ) {
while( !feof($fp) ){
echo fread($fp, 1024);
flush(); // you have to flush buffer
}
fclose($fp);
}
这篇关于php shell_exec实时更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文