douhong6187 2013-01-29 23:17
浏览 28
已采纳

长PHP脚本和回声/打印

I have some PHP scripts that can be called either from the command line or as a webpage (where the arguments are passed from other web pages using $GET or $POST).

They can take a while to execute, let’s say 5 minutes.

The scripts include some “echo” & “print” calls which allow me to know what is happening during the execution in real time.

The problem is that, in webpage mode, those echo calls don’t print anything in the browser till the end of the script execution. Or sometimes, half the echos appears after 2 minutes and the rest at the end.

Is there a simple way to make my print()/echo() calls appear in real time when my script are called in “webpage mode”?

Thanks in advance.

  • 写回答

3条回答 默认 最新

  • dongmubi4375 2013-01-29 23:27
    关注

    flush() may or may not work depending on the browser and size of the output (see: PHP Flush() not working in Chrome)

    Apache can also buffer output if mod_gzip is enabled.

    Your best bet is to log into a db/session/fs and have JS on client side polling for updates.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!