mmilano wrote:you would think, wouldn't ya 🙂 .. i have a php 5.0.4 installed on a fedora box and a script that does this. it would not flush until i added the ob_flush().
It must be a 5.0 bug, because just flush() works fine on 5.1.1 and 5.1.2.
If you need to send some extra data to get a good flush, you can use str_pad:
echo str_pad('',9096);
To demonstrate use, here is a quick sample script that outputs numbers 1-6 over a course of ~1 minute (~1 number every 10 seconds). I'm only using flush() and this works fine in PHP 5.1.2. You might have to add ob_flush() for earlier PHP versions as mmilano suggested. I'm using 9096 because originally I needed that much to get Safari to work, however, testing again at 4096 and both Safari and Firefox will work at that level as well. However, I am included to stay a bit above that since Safari did show problems earlier:
<?php
for ($i = 1; $i <= 6; $i++) {
echo $i . '<br>';
echo str_pad('',9096)."\n";
// flush output
flush();
// sleep.... sleeeppp...
sleep(10);
}