Hi Please View Below Code :
\\n\";
for( $i = 0 ; $i < 10 ; $i++ )
{
echo \"$i
\\n\";
You need to add a .htaccess
file to disable gzip output
<IfModule mod_env.c>
SetEnv no-gzip 1
</IfModule>
Some browsers need to receive at least 256 characters before they start to render. Have you already tried to stuff more output like:
echo str_repeat(' ', 50) . "$i<br />\n";
EDIT:
Under Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9
I was able to reproduce the problem of the OP by setting
zlib.output_compression = On
Turning it off again by
zlib.output_compression = Off
made the script work as wanted.
It is correct. Works fine for me from CLI running PHP 5.3.3. If it's not working for you, your PHP install may have output buffering disabled.
I would also suggest putting ob_end_flush() at the end of your script to close the output buffer.
Try removing the call to ob_start()
on your first line : there is no need for you to enable output buffering -- and it probably causes troubles, here.
I've tested your code :
ob_start()
is called on the first line, I only see the output when the script finishes, after 10 secondsob_start()
, then, I see one line of output every second, as soon as it's displayed on the standard output.I've discovered that this was due to Apache's gzip compression being in use for my case.
To turn gzip off for the 'flushing' script only, I created a new .htaccess
file in the directory where the continuous output script resides, with the following:
<IfModule mod_env.c>
SetEnv no-gzip 1
</IfModule>
Flushing is working as expected again.
One sneaky issue with IE8 and flush(); is that if you're "flushing" out rows in a table. IE will only display tables when they're complete. This was my issue, and changing containers from table rows to divs solved the problem.