for($i=0; $i<5; $i++){
echo $i.'<br>';
sleep(1);
}echo str_repeat(" ",1024);//这里重复输出一个空白
for($i=0; $i<5; $i++){
echo $i."<br/>";
flush();
sleep(1);
}
运行for($i=0; $i<5; $i++){
echo file_get_contents('f.txt').$i.'<br/><br/><br/><br/>';
sleep(2);
}ob_start();
for($i=0; $i<5; $i++){
echo file_get_contents('f.txt').$i.'<br/><br/><br/><br/>';
sleep(2);
}ob_start();
echo "abc-";
header("content-type:text/html;charset=utf-8");
echo "hello-";
ob_end_flush();
echo "aa-";
echo ob_get_contents();
运行结果:abc-hello-aa-abc-hello-aa-
f、output_buffering=Off,使用ob_start()ob_start();
echo "abc-";
header("content-type:text/html;charset=utf-8");
echo "hello-";
ob_end_flush();
echo "aa-";
echo ob_get_contents();
查看更多关于PHP中output_buffering详解的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did30573