I'm using PHP 5.3.4 with Apache 2.2.17 on the Home windows 7 x64 system. I must have my PHP page output the effect of a system get in touch with real-time for you to anyone's browser. To that particular finish, I've set up output_buffering=Off in php.ini and produced this code:

system('ping -n 10 www.google.com');

Caused by the ping is printed in tangible-time, however i will also get a PHP diagnostic error and callstack towards the top of my page that states:

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 should i do in order to either correct or suppress this error?

Update Basically change ob_end_flush() to $a = 1/0; I recieve an identical error and also the output is realtime in most browsers. Could it be something about how a exception is printed that triggers this to operate?

some web browsers buffer the very first x bytes before linked with emotions . render a webpage, under certain conditions.

try just outputting plenty of whitespace first

Inside your code, the mistake is fairly simple to interpret.

You call ob_end_flush() online 3, but (such as the error states), there's no output to purge. Essentially, line 3 is useless because no output continues to be sent, so removing the road will fix the mistake. If this sounds like integrated into a bigger file, you will need to help keep ob_end_flush() because some output may curently have been taken.

EDIT: As you have to purge it, either:

a: add ob_start(); to the top file.

b: replace ob_end_flush(); with flush();

EDIT2: Because the first did not appear to operate, this is actually the best I'm able to offer: How to echo output in real time, (before script finishes)?

doctor_finish_flush() flushes the php output buffer, as well as an energetic output buffer produced with doctor_start().

I believe you want to call flush() to transmit the information towards the client.

system('ping -n 10 www.google.com');

I've got a solution that actually works, but it's non-performant and icky. I throw the best, but hide the exception dialog.


    // Something about the way exceptions are thrown causes Firefox and Chrome 
    // to be able to display the results of the system call in real-time rather
    // than having to wait for the call to complete. So, I just hide the 
    // exception message. IE9 works with or without this.
    echo "<div style=\"display:none\">";
    $a = 1/0;
    echo "</div>";

    echo "<pre>";
    system('ping -n 5 www.google.com');
    echo "</pre>";

To auto-scroll to the foot of the page, I then add javascript:

<script language="javascript">
var int = self.setInterval("window.scrollBy(0,1000);", 200);
    // insert above php code here
    // stop scrolling when the execution finishes
    echo '<script language="javascript">int = window.clearInterval(int);</script>';


@Chris's answer shows a far greater solution.

echo '<div style="display:none">';
for ($a = 0; $a < 768; $a++)
    echo ' ';
echo '</div>';