tags:

views:

34

answers:

1

ob_start();

for($i=0; $i < 10; $i++) {     
  echo $i, ' '; 
  ob_flush(); 
  flush(); 
  sleep(1); 
}

Expected: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 appearing incrementally every second in the browser.

Result: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 at once AFTER ten seconds.

I just couldn't get output buffering to work.

A: 

I believe its a bug in a particular version of PHP, solution can be found here...

http://www.php.net/manual/en/function.ob-flush.php#85383

michael