Home  >  Article  >  Backend Development  >  Usage of ob_flush() function and flush() function in php

Usage of ob_flush() function and flush() function in php

怪我咯
怪我咯Original
2017-07-06 10:41:531976browse

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(&#39;m0sh1&#39; ,1000);   
  for($i=0;$i<4;$i++) { 
    echo $i.&#39;<br />&#39;; 
    ob_flush(); 
    flush(); 
    sleep(1); 
  } 
?> 
<?php 
//header("content-type:text/html;charset=&#39;utf-8&#39;"); 
//提示错误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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn