问题描述
我搬到我的文件到新的服务器,我有一个脚本,即时显示在每个回声
到浏览器的输出,而这是不工作的新服务器上。下面是我的测试code:
I moved my files to a new server and I had a script that instantly showed output on every echo
to the browser, but this isn't working on the new server. Here is my test code:
@ini_set('output_buffering', 0); @ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush();
ob_implicit_flush(1);
ignore_user_abort(true); set_time_limit(0);
$max_wait_time = 30;
$begin_time = microtime(true);
$elapsed_time = 0;
while(!connection_aborted()) {
echo $i++.str_repeat(' ', 1020).'<br/>';
flush(); ob_flush();
usleep(1000000);
if($elapsed_time > $max_wait_time){ break; }
$elapsed_time++;
}
我试过几件事情已经成为以上。但在和冲洗转向输出缓冲并没有为我工作。我在Chrome和Firefox测试这一点,他们在最后都只有产量的一切。
I've tried a few things which has become the above. But turning output buffering on and flushing hasn't worked for me. I have tested this on Chrome and Firefox, they both just output everything at the end.
任何想法?
推荐答案
从 刷新
文档:
平齐()可能无法重写
您的网站的缓冲方案
服务器和其对任何没有影响
客户端缓冲的浏览器。
[...]
几台服务器,特别是在Win32中,
将静象缓冲器从输出的
脚本,直到它之前终止
发送结果到
浏览器。
Several servers, especially on Win32, will still buffer the output from your script until it terminates before transmitting the results to the browser.
服务器Apache的模块一样
mod_gzip,可能自己的缓冲
这将导致flush()将不会导致
在立即被发送到
客户端。
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.
机会是很高,你改成不同的Web服务器(或Web服务器配置),其中输出前缓冲整个脚本的输出。
Chances are high that you changed to a different web server (or web server configuration), which buffers the output of the whole script before outputting it.
这篇关于如何正确显示输出在每个回显所有的浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!