如何刷新输出的每个`echo`后打电话? [英] How to flush output after each `echo` call?
问题描述
我有一个PHP脚本,只生产记录到客户端。结果
当我赞同的东西,我希望它被转移到即时客户端。结果
(因为在脚本处理过程中,页面是空白的)结果
我已经用 ob_start()
和发挥各地使用ob_flush()
,但他们没有工作。
I have a php script that only produces logs to the client.
When I echo something, I want it to be transferred to client on-the-fly.
(Because while the script is processing, the page is blank)
I had already played around with ob_start()
and ob_flush()
, but they didn't work.
什么是最好的解决方案?
What's the best solution?
PS:这是一个有点脏把冲洗在年底回声
调用...
PS: it is a little dirty to put a flush at the end of the echo
call...
编辑:无论是答案的工作,PHP或Apache故障?
Neither the Answers worked, PHP or Apache Fault?
推荐答案
编辑:
我在阅读手册页面上的赞扬和整个,指出<$错误 C $ C> ob_implicit_flush 的不工作的和下面是它的一个解决方法:
I was reading the commends on the manual page and came across a bug that states that ob_implicit_flush
does not work and the following is a workaround for it:
ob_end_flush();
# CODE THAT NEEDS IMMEDIATE FLUSHING
ob_start();
什么甚至有可能发生的是,客户端没有收到来自服务器的数据包,直到该服务器已经建立了足够的字符发送它认为一个数据包发送价值
What may even be happening is that the client does not receive the packet from the server until the server has built up enough characters to send what it considers a packet worth sending.
老答案:
您可以使用<一个href=\"http://www.php.net/manual/en/function.ob-implicit-flush.php\"><$c$c>ob_implicit_flush$c$c>它会告诉输出缓冲关闭缓冲一段时间:
You could use ob_implicit_flush
which will tell output buffering to turn off buffering for a while:
ob_implicit_flush(true);
# CODE THAT NEEDS IMMEDIATE FLUSHING
ob_implicit_flush(false);
这篇关于如何刷新输出的每个`echo`后打电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!