所以我尝试过在脚本仍在执行时显示结果 https://stackoverflow.com/questions/5415665/show-results-while-script-is-still-executing
但由于某种原因它不起作用,所以这是我到目前为止所拥有的:
ob_start();
include "../../common.php";
set_time_limit (0);
$start = (string) $_GET['start'];
$end = (string) $_GET['end'];
for($i = $start; strcmp($i, $end); $i = bcadd($i, 1)){
echo $i;
ob_flush();
}
ob_end_flush();
更新的代码
*请注意,此代码尚未运行!
set_time_limit(0);
$start = $_GET['start'];
$end = $_GET['end'];
for(;$start < $end;$start++){
$content = file_get_contents("[some internal page]");
echo $content;
usleep(10);
flush();
}
尝试添加呼叫flush() https://www.php.net/manual/en/function.flush.php致电后ob_flush()
。仅当您的服务器配置为能够执行此操作时,这才有效,并且不能保证客户端会明智地处理它,但这是您最好的选择。
我在这里遇到的一个症结是你有zlib.output_compression http://www.php.net/manual/en/zlib.configuration.php#ini.zlib.output-compression配置好的你绝对不能这样做,句号。 zlib 输出压缩过程在执行任何代码之前启动,并且无法在运行时由脚本控制ini_set()
等等。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)