从php回声“随它去”; [英] echo from php "as it goes"

查看:73
本文介绍了从php回声“随它去”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在脚本结束之前打印内容时,从php脚本打印结果的方法是什么?我尝试使用输出缓冲区,将echo()之间的sleep()进行测试,但脚本执行后总是显示结果。

what was the way to print results from a php script while it's printing stuff before the script ends? i tried to play with output buffer, putting sleep() between echos to test but the result is always showed after the script executes. Is it a browser-side thing too?

推荐答案

您可以在PHP脚本中尝试刷新所有当前输出的所有内容吗?到用户浏览器的是对 ob_flush 的调用,但这实际上还取决于许多其他因素。

All you could do in your PHP script to try to flush all the current output to the user's browser is a call to ob_flush, but it actually depends on many other things as well.

HTTP服务器具有自己的缓冲,浏览器可能不会立即呈现它收到的每个数据包。就像在不同级别上有很长的缓冲区流水线一样,在浏览器中看到任何内容之前,都必须清除所有缓冲区,而PHP输出缓冲区处于最高级别。

The HTTP server has its own buffering, and the browser may not instantly render every packet it receives. It's like a long pipeline of buffers at different levels that all have to be flushed before you see anything in the browser, and the PHP output buffer is at the highest level.

这篇关于从php回声“随它去”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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