为什么PHP脚本在等待“完成脚本"?在任何回声/输出之前? [英] Why is a PHP script waiting "to finish script" before any echo/output?

查看:56
本文介绍了为什么PHP脚本在等待“完成脚本"?在任何回声/输出之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑一个简单的脚本

<?php 
echo "hi";
foreach ($_GET['arr'] as $a)
{
 echo $a ."<br>";
}
echo "<p>Masel tov</p>";
foreach ($_GET['arr2'] as $a)
{
 echo $a ."<br>";
}

我希望脚本不断回显.相反,脚本在完成时会一次全部回显.脚本完成1分钟后,即使是第一个" hi "也会被回显.

i expect the script to echo continuously. Instead the script does echo all-at-once when finished. Even the first "hi" gets echoed after 1 minute when the script finishes.

有设置防止这种情况发生的原因吗?

Is there a setting to prevent this from happen or why is that so?

推荐答案

有一个功能 ob_implicit_flush ,可用于在每次输出调用之后启用/禁用自动刷新.但是在使用它之前,请先看一下PHP手册上的注释.

There is a function ob_implicit_flush that can be used to enable/disable automatic flushing after each output call. But have a look at the comments on the PHP manual before using it.

这篇关于为什么PHP脚本在等待“完成脚本"?在任何回声/输出之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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