【nginx.conf中确认以下配置】
http {
......
gzip off;
server {
location ~ \.php$ {
......
proxy_buffering off;
fastcgi_keep_conn on;
}
}
......
}
【php.ini中确认以下配置】
output_buffering = off
【PHP代码】
$str = '这里是一句话,要一个字一个字的输出。';
ob_end_clean();
for ($i = 0; $i < $str, 'UTF8'); $i++) {
echo mb_substr($str, $i, 1);
ob_flush();
flush();
// 5毫秒
usleep(50000);
}
ob_end_flush();