Home  >  Article  >  Backend Development  >  What is the difference between ob_flush and flush?

What is the difference between ob_flush and flush?

一个新手
一个新手Original
2017-09-06 16:18:571343browse

The description of ob_flush/flush in the manual is that they both refresh the output buffer and need to be used in conjunction, so it will cause confusion to many people...

In fact, the operation objects of the two are different. In some cases , flush does nothing at all..

ob_* series functions operate the output buffer of PHP itself.

So, ob_flush refreshes the buffer of PHP itself.

And flush, strictly speaking, this only has practical effect when PHP is installed as apache Module (handler or filter). It refreshes the buffer of WebServer (can be considered specifically apache).

Under sapi of apache module, flush will pass the flush member function pointer of sapi_module , indirectly calling the api of apache: ap_rflushrefreshes the output buffer of apache. Of course, the manual also says that there are some other modules of apache that may Change the result of this action..

有些Apache的模块,比如mod_gzip,可能自己进行输出缓存,
这将导致flush()函数产生的结果不会立即被发送到客户端浏览器。 

甚至浏览器也会在显示之前,缓存接收到的内容。例如 Netscape
浏览器会在接受到换行或 html 标记的开头之前缓存内容,并且在
接受到 </table> 标记之前,不会显示出整个表格。 

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

So, the correct order to use the two is. First ob_flush, then flush,

Of course, under other sapi, you can not call flush, just However, in order to ensure the portability of your code, it is recommended to use it together.


The above is the detailed content of What is the difference between ob_flush and flush?. 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