实时打印过程输出 [英] printing process output in realtime

查看:85
本文介绍了实时打印过程输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7 x64系统上将PHP 5.3.4与Apache 2.2.17一起使用.我想让我的PHP页面将system调用的结果实时输出到用户的浏览器.为此,我在php.ini中配置了output_buffering=Off并创建了以下代码:

I am using PHP 5.3.4 with Apache 2.2.17 on a Windows 7 x64 system. I would like to have my PHP page output the result of a system call in real-time to the user's browser. To that end, I have configured output_buffering=Off in php.ini and created this code:

<?php
ob_implicit_flush(true);
ob_end_flush();
system('ping -n 10 www.google.com');
?>

ping的结果是实时打印的,但是我在页面顶部也显示了PHP诊断错误和调用堆栈,

The result of the ping is printed in real-time, but I also get a PHP diagnostic error and callstack at the top of my page that says:

Notice: ob_end_flush() [ref.outcontrol]: failed to delete and flush buffer. No buffer to delete or flush in index.php on line 3

我该怎么做才能纠正或抑制此错误?

What do I need to do to either correct or suppress this error?

更新 如果将ob_end_flush()更改为$a = 1/0;,则会收到类似的错误,并且在所有浏览器中输出都是实时的.是否与导致异常工作的异常打印方式有关?

Update If I change ob_end_flush() to $a = 1/0; I get a similar error and the output is realtime in all browsers. Is it something about the way the exception is printed that causes this to work?

推荐答案

某些网页浏览器在某些条件下会在开始呈现页面之前先缓冲前x个字节.

some web browsers buffer the first x bytes before they start to render a page, under certain conditions.

尝试先输出大量空白

这篇关于实时打印过程输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆