srs
srs

Reputation: 21

php implicit_flush command not working correctly

I have been trying to get my server to be able to flush an echo or print after sleeping and have been unsuccessful. Im using PHP 5.3.24 under Windows. There are literally dozens and dozens of suggestions out there, just about all of which I tried, none of which has worked. Here is some code that I thought may have worked:

ob_implicit_flush(true);
ob_end_flush();
for ($i=0; $i<10; $i++) {
   echo $i.'<br>';
   sleep(1);
}

This code will not do anything for 9 seconds and then output everything.

I have tried:

-outputting over 1000 characters at the top of the page since there was a suggestion that the browser my be caching,

-added header( 'Content-type: text/html; charset=utf-8' ); header("Cache-Control: no-cache, must-revalidate");header ("Pragma: no-cache");

-used flush(); and ob_flush(); commands,

-made output_buffering = Off, zlib.output_compression = Off, and implicit_flush = Yes (or implicit_flush = On, seen both examples) in the php.ini,

-also tried @ini_set('zlib.output_compression',0); @ini_set('implicit_flush',1); @ob_end_clean(); set_time_limit(0);

Plus others that I am probably forgetting.

Is there something I am missing? Thanks.

Upvotes: 2

Views: 1502

Answers (1)

a4c8b
a4c8b

Reputation: 925

Looks like browser caching. Try this (tested successfully):

ob_implicit_flush(true);
ob_end_flush();
for ($i=0; $i<10; $i++) {
   echo $i.'<br>';
   echo str_repeat(' ', 1024);
   sleep(1);
}

Not a fine solution, but it proves that you simple have to put more characters into the browser buffer.

Upvotes: 1

Related Questions