如何使echo立即在PHP中打印出来? [英] how to make echo print out right away in PHP?

查看:115
本文介绍了如何使echo立即在PHP中打印出来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,直到整个页面执行完毕,它才会打印出任何内容.

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?

但不能多次调用ob_end_flush(),这不是我想要的.

But not by calling ob_end_flush() multiple times, which is not what I want.

希望你们得到了我吗?

推荐答案

如果打开了输出缓冲,则刷新它是向浏览器输出任何内容的唯一方法.如果要立即输出,请关闭输出缓冲.如果不在您的控制范围内,则可以在脚本的srart处调用ob_end_flush(),这将关闭输出缓冲.但是,没有办法让某些消息通过,而有些则不允许(不编写自定义回显/打印功能)

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()将刷新并关闭最上面的输出缓冲区.要确保所有输出缓冲区均已关闭并刷新,您可以轻松地执行以下操作:

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:

while (@ob_end_flush());

这篇关于如何使echo立即在PHP中打印出来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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