Home >Backend Development >PHP Tutorial >php中ob_flush函数和flush函数用法分析_PHP

php中ob_flush函数和flush函数用法分析_PHP

WBOY
WBOYOriginal
2016-06-01 11:06:16929browse

本文实例分析了php中ob_flush函数和flush函数用法。分享给大家供大家参考。具体如下:

ob_flush()函数: 取出PHP buffering中的数据,放入server buffering

flush()函数: 取出Server buffering的数据,放入browser buffering

例如代码:

<&#63;php 
  echo str_repeat('m0sh1' ,1000);   
  for($i=0;$i<4;$i++) { 
    echo $i.'<br />'; 
    ob_flush(); 
    flush(); 
    sleep(1); 
  } 
&#63;> 
<&#63;php 
//header("content-type:text/html;charset='utf-8'"); 
//提示错误Cannot modify header information - headers already sent by 
&#63;>

执行发现

这里代码输出结果是一行一行输出的,

注意:正确使用二者的顺序是. 先ob_flush, 然后flush

希望本文所述对大家的php程序设计有所帮助。

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