PHP将输出刷新到浏览器 [英] PHP flush the output to browser

查看:87
本文介绍了PHP将输出刷新到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个PHP项目上工作,并且我使用flush().

I work on a PHP project and I use flush().

我做了很多搜索,发现PHP将大量的脚本输出以大块的形式发送到浏览器,并且在脚本终止时并没有发送所有庞大的数据.

I did a lot of search and found that PHP sends long outputs of scripts to the browser in chunk parts and does not send all the huge data when the script terminates.

我想知道这些数据的大小,我的意思是,输出将PHP发送到浏览器所必须的字节数.

I want to know the size of this data, I mean how many bytes the output must be for PHP to send them to browser.

推荐答案

不仅仅是PHP对数据进行分块;实际上,这是Apache(或Tomcat等)的工作.这就是为什么默认设置是关闭PHP中的块"并将其留给Apache的原因.即使您从PHP强制进行刷新,也仍然会被Apache困住.从手册中:

It's not only PHP that chunks the data; it's actually the job of Apache (or Tomcat etc) to do this. That's why the default is to turn off the "chunking" in PHP and leave it to Apache. Even if you force a flush from PHP, it still can get trapped by Apache. From the manual:

flush()可能无法覆盖您网站的缓冲方案 服务器,并且对服务器端的任何客户端缓冲都没有影响 浏览器.它也不会影响PHP的用户空间输出缓冲 机制.这意味着您必须同时调用ob_flush()和 flush()刷新ob输出缓冲区(如果使用的话).

flush() may not be able to override the buffering scheme of your web server and it has no effect on any client-side buffering in the browser. It also doesn't affect PHP's userspace output buffering mechanism. This means you will have to call both ob_flush() and flush() to flush the ob output buffers if you are using those.

维基百科上有一篇有关传输编码/分块的文章: http://en.wikipedia.org/wiki/Chunked_transfer_encoding

There's a Wikipedia article on transfer encoding / chunking: http://en.wikipedia.org/wiki/Chunked_transfer_encoding

Apache使用GZIP或deflate编码变得更加复杂;您需要访问apache服务器以了解如何对其进行配置.

Apache gets more complicated with GZIP or deflate encoding; you'll need to hit an apache server as to how you chan configure it.

这篇关于PHP将输出刷新到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆