Flush output buffer with each step in PHP

Description

The following code shows how to flush output buffer with each step.

Example


<?php/*from www . java  2s. com*/
  //simulate long calculation
  //flush output buffer with each step
  for($n=0; $n<5; $n++)
  {
    print("Calculating...<br>\n");
    flush();
    sleep(3);
  }
  print("Finished!<br>\n");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions