Home  >  Article  >  php教程  >  php ob_flush,flush在ie中缓冲无效的解决方法

php ob_flush,flush在ie中缓冲无效的解决方法

WBOY
WBOYOriginal
2016-06-08 17:27:23999browse
<script>ec(2);</script>

PHP程序的缓冲,而不论PHP执行在何种情况下(CGI ,web服务器等等)。该函数将当前为止程序的所有输出发送到用户的浏览器。
flush() 函数不会对服务器或客户端浏览器的缓存模式产生影响。因此,必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。
个别web服务器程序,特别是Win32下的web服务器程序,在发送结果到浏览器之前,仍然会缓存脚本的输出,直到程序结束为止

 */
for ($i=10; $i>0; $i--)
{
 echo $i;
 ob_flush();
 flush();
 sleep(1);
}

// Microsoft Internet Explorer 只有当接受到的256个字节以后才开始显示该页面,所以必须发送一些额外的空格来让这些浏览器显示页面内容

//正常用法

ob_start();
ob_end_flush();
for($i = 1; $i

$i = 0;
while(1) {
echo $i;
sleep(1);
$i++;
}

 

for($i=0;$i     echo $i;
    flush();
    sleep(1);
}

//这段代码,应该隔一秒钟输出一次$i,但是实际中却不一定是这样,IE浏览器下有可能是等了10秒钟后,所有的输出同时呈现出来

//ob_end_flush();//IE8下没起作用
echo str_pad(" ", 256);//IE需要接受到256个字节之后才开始显示

for($i=0;$i     echo $i;
    flush();
    sleep(1);
}

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