Home  >  Article  >  Backend Development  >  关于 output_buffering 一些疑义

关于 output_buffering 一些疑义

WBOY
WBOYOriginal
2016-06-13 12:56:10765browse

关于 output_buffering 一些疑问
我在网上看到 这么篇文件
http://www.cnblogs.com/zemliu/archive/2012/05/11/2495293.html

上面说
PHP的输出顺序

1.打开了php输出缓存: echo,print -> php output_buffring -> server buffering -> browser buffering -> browser display

2.未打开php输出缓存: echo,print -> server buffering -> browser buffering -> browser display

这个是对的吗?????


还有
ob_flush()函数: 取出PHP buffering中的数据,放入server buffering
flush()函数: 取出Server buffering的数据,放入browser buffering

所以要强制把缓冲区的东西输出的时候,先写ob_flush()   在写 flush()
是这样吗


------解决方案--------------------
对的,是这样的

不过对于 ob_flush() 和 flush() 谁先谁后,要取决于的控制需要
echo 'a';
ob_flush();
flush();
sleep(1);

echo 'a';
flush();
ob_flush();
sleep(1);
的区别在于,前者立刻就看到 a,而后者要等一秒才看到
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