This article analyzes the usage of ob_flush function and flush function in php with examples. Share it with everyone 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 data from Server buffering and put it into browser buffering
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 ?>
Perform Discovery
The output result of this code is output line by line,
Note: The correct order to use the two is. First ob_flush, then flush
I hope this article will be helpful to everyone’s PHP programming design.