This article analyzes the usage of ob_flush function and flush function in PHP. Share it for your reference. The details are as follows:
ob_flush() function: Take out the data in PHP buffering and put it into server buffering
flush() function: Take out the server buffering data and put it in browser buffering
For example code:
<?php echo str_repeat('m0sh1' ,1000); for($i=0;$i<4;$i++) { echo $i.'<br />'; ob_flush(); flush(); sleep(1); } ?> <?php //header("content-type:text/html;charset='utf-8'"); //Cannot modify header information - headers already sent by?>
Execution Discovery
The output result of this code is output line by line.
Note: The order of using both is. First ob_flush, then flush
I hope this article will be helpful to everyone's PHP programming.