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:
<?php ob_implicit_flush(true); ob_end_flush(); 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?
$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.
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:
ob_start(); to the top file.
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.
<?php ob_implicit_flush(true); flush(); 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.
<?php ob_implicit_flush(true); // 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>"; ?>
@Chris's answer shows a far greater solution.
echo '<div style="display:none">'; for ($a = 0; $a < 768; $a++) echo ' '; echo '</div>';