From PHP Manual:
flush() may not be able to override the buffering scheme of your web server and it has no effect on any client-side buffering in the browser. It also doesn't affect PHP's userspace output buffering mechanism. This means you will have to call both ob_flush() and flush() to flush the ob output buffers if you are using those.
echo "Hello!";
flush();
ob_flush();
for($i = 0; $i < 10; $i ++) {
echo $i;
//5-10 sec execution time
flush();
ob_flush();
}
-or- you can flush and turn off Buffering
<?php
//Flush (send) the output buffer and turn off output buffering
while (ob_get_level() > 0)
ob_end_flush();
echo "Hello!";
for($i = 0; $i < 10; $i ++) {
echo $i . "
";
}
?>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…