PHP Function Reference

PHP ob_implicit_flush() Function



The PHP ob_implicit_flush() function enables or disables the implicit flushing. When enabled, implicit flushing sends output directly to the browser as soon as it is produced so that calls to the flush() function are not needed.

Syntax

ob_implicit_flush(flag)

Parameters

flag Optional. Set to true to turn on the implicit flushing. Default is false.

Return Value

No value is returned.

Example: ob_implicit_flush() example

The example below shows the usage of ob_implicit_flush() function.

<?php
//turning on the implicit flushing
ob_implicit_flush(true);

//display each line at a time 
//with a pause of 1 second
for ($i = 1; $i<=3; $i++){
  
  //some browsers will not display the content
  //if it is too short. Therefore using 
  //str_pad() to make the output long enough
  echo "Line $i content. <br>";
  echo str_pad('', 4096)."\n";   

  sleep(1);
}

echo "Done.";
?>

The output of the above code will be:

Line 1 content.
Line 2 content.
Line 3 content.
Done.

❮ PHP Output Control Reference