This article mainly introduces the ob_flush function and flush function usage in php. It analyzes the functions of ob_flush function and flush function and related usage skills with examples. It has certain reference. Value, friends in need can refer to
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 in Server buffering , put into 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 the code here is output line by line,
Note: The correct order to use the two is. ob_flush first, then flush
The above is the detailed content of Usage of ob_flush() function and flush() function in php. For more information, please follow other related articles on the PHP Chinese website!