Home > Backend Development > PHP Tutorial > flush()函数无效?不能实时刷新输出,怎么解决呢

flush()函数无效?不能实时刷新输出,怎么解决呢

WBOY
Release: 2016-06-13 12:45:38
Original
1172 people have browsed it

flush()函数无效?不能实时刷新输出,如何解决呢?

本帖最后由 zhoumengkang 于 2013-05-28 13:46:14 编辑 测试代码如下:
<?php<br />
for($i=0;$i<5;$i++){  <br />
	echo '<br/>abc___'.$i;<br />
	ob_flush();<br />
	flush();<br />
	sleep(1);<br />
}<br />
ob_end_flush();<br />
?> 
Copy after login

理论上应该是1秒出来一条是吧?但是我测试的结果是5秒之后才一起出来。
网上查了下有这样说的“个别web服务器程序,特别是Win32下的web服务器程序,在发送结果到浏览器之前,仍然会缓存脚本的输出,直到程序结束为止。 ”我这个是64位的windows的本地xampp的集成环境。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template