By default it will not print out anything until the whole page has finished executing.
默认情况下,在整个页面执行完毕之前,它不会打印出任何内容。
Is there any function that can make it flush out right away?
是否有任何功能可以立即冲洗掉?
But not by calling ob_end_flush()
multiple times, which is not what I want.
但不是多次调用ob_end_flush(),这不是我想要的。
Hope you guys got me?
希望你们有我吗?
4 个解决方案
#1
If output buffering is on, then flushing it is the only way to output anything to the browser. If you want to output right away then turn of output buffering. If that is not in your control you can just call ob_end_flush() at the srart of your script which will turn the output buffering off. There is no way however to let some messages pass, and some not (without writing custom echo/print functions)
如果打开输出缓冲,则刷新它是向浏览器输出任何内容的唯一方法。如果你想立即输出然后转动输出缓冲。如果不是在你的控制,你只需调用ob_end_flush()函数在脚本的srart将关闭输出缓冲关闭。然而,没有办法让一些消息通过,有些则没有(没有编写自定义echo / print函数)
calling ob_end_flush() will flush and turn off the top most output buffer. To make sure all output buffers are turned off and flushes you can easily do this:
调用ob_end_flush()将刷新并关闭最顶层的输出缓冲区。要确保关闭所有输出缓冲区并刷新,您可以轻松地执行此操作:
while (@ob_end_flush());
#2
It will depend on your webserver. Calling flush will flush the output of whatever current buffer is open, however, as it says on the linked page:
这取决于您的网络服务器。调用flush将刷新当前打开的缓冲区的输出,但是,如链接页面上所述:
flush() has no effect on the buffering scheme of your web server or the browser on the client side. Thus you need to call both ob_flush() and flush() to flush the output buffers.
flush()对Web服务器或客户端浏览器的缓冲方案没有影响。因此,您需要同时调用ob_flush()和flush()来刷新输出缓冲区。
Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.
多个服务器,尤其是Win32上的服务器,仍将缓冲脚本的输出,直到它终止,然后再将结果传输到浏览器。
Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.
像mod_gzip这样的Apache服务器模块可能会自行缓冲,这会导致flush()不会导致数据立即发送到客户端。
#3
You could turn off output-buffering on your development/test-server. Change the output_buffering variable in your php.ini configuration file.
您可以在开发/测试服务器上关闭输出缓冲。更改php.ini配置文件中的output_buffering变量。
#4
ob_end_flush() will throw a notice if it is used at the top of the script when there is no buffer to flush. This may be an issue if you are planning to set cookies or headers. I found it did not affect the buffering on my shared server (Rackspace Reseller).
如果没有要刷新的缓冲区,ob_end_flush()将在脚本顶部使用它时会抛出通知。如果您计划设置cookie或标头,这可能是一个问题。我发现它不会影响我的共享服务器(Rackspace Reseller)上的缓冲。
#1
If output buffering is on, then flushing it is the only way to output anything to the browser. If you want to output right away then turn of output buffering. If that is not in your control you can just call ob_end_flush() at the srart of your script which will turn the output buffering off. There is no way however to let some messages pass, and some not (without writing custom echo/print functions)
如果打开输出缓冲,则刷新它是向浏览器输出任何内容的唯一方法。如果你想立即输出然后转动输出缓冲。如果不是在你的控制,你只需调用ob_end_flush()函数在脚本的srart将关闭输出缓冲关闭。然而,没有办法让一些消息通过,有些则没有(没有编写自定义echo / print函数)
calling ob_end_flush() will flush and turn off the top most output buffer. To make sure all output buffers are turned off and flushes you can easily do this:
调用ob_end_flush()将刷新并关闭最顶层的输出缓冲区。要确保关闭所有输出缓冲区并刷新,您可以轻松地执行此操作:
while (@ob_end_flush());
#2
It will depend on your webserver. Calling flush will flush the output of whatever current buffer is open, however, as it says on the linked page:
这取决于您的网络服务器。调用flush将刷新当前打开的缓冲区的输出,但是,如链接页面上所述:
flush() has no effect on the buffering scheme of your web server or the browser on the client side. Thus you need to call both ob_flush() and flush() to flush the output buffers.
flush()对Web服务器或客户端浏览器的缓冲方案没有影响。因此,您需要同时调用ob_flush()和flush()来刷新输出缓冲区。
Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.
多个服务器,尤其是Win32上的服务器,仍将缓冲脚本的输出,直到它终止,然后再将结果传输到浏览器。
Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data being sent immediately to the client.
像mod_gzip这样的Apache服务器模块可能会自行缓冲,这会导致flush()不会导致数据立即发送到客户端。
#3
You could turn off output-buffering on your development/test-server. Change the output_buffering variable in your php.ini configuration file.
您可以在开发/测试服务器上关闭输出缓冲。更改php.ini配置文件中的output_buffering变量。
#4
ob_end_flush() will throw a notice if it is used at the top of the script when there is no buffer to flush. This may be an issue if you are planning to set cookies or headers. I found it did not affect the buffering on my shared server (Rackspace Reseller).
如果没有要刷新的缓冲区,ob_end_flush()将在脚本顶部使用它时会抛出通知。如果您计划设置cookie或标头,这可能是一个问题。我发现它不会影响我的共享服务器(Rackspace Reseller)上的缓冲。