我这里通过,你那flush()无效? flush (PHP 3, PHP 4 >= 4.0.0)flush -- Flush the output buffer Note: flush() has no effect on the buffering scheme of your webserver or the browser on the client side. <? for ($i;$i<10;$i++){ print($i."<BR>"); flush(); sleep(1); } ?>
PHP Version 4.0.6 + winxpyou can try other functionsLXXII. Output Control FunctionsTable of Contents flush — Flush the output buffer ob_clean — Clean (erase) the output buffer ob_end_clean — Clean (erase) the output buffer and turn off output buffering ob_end_flush — Flush (send) the output buffer and turn off output buffering ob_flush — Flush (send) the output buffer ob_get_contents — Return the contents of the output buffer ob_get_length — Return the length of the output buffer ob_get_level — Return the nesting level of the output buffering mechanism ob_gzhandler — ob_start callback function to gzip output buffer ob_implicit_flush — Turn implicit flush on/off ob_start — Turn on output buffering
<?
for ($i;$i<10;$i++)
{
echo $i."<BR>";
sleep(1);
}
?>
for ($i;$i<10;$i++){
print($i."<BR>");
flush();
sleep(1);
}
?>
我用php+js实现:<body>
<div id=xxx></div>
<?
echo "<script>\n";
echo "var arr=new Array();\n";
for($i=0; $i < 10; $i++){
echo "arr[$i]=$i;\n";
}
echo "</script>\n";
?>
<script>
n=0;
function listXXX(){
if(n>=arr.length){
clearInterval(aa);return;
}
xxx.innerHTML+=arr[n]+"<BR>";
n++;
}
aa=setInterval("listXXX()",1000)
</script>
</body>
flush
(PHP 3, PHP 4 >= 4.0.0)flush -- Flush the output buffer Note: flush() has no effect on the buffering scheme of your webserver or the browser on the client side. <?
for ($i;$i<10;$i++){
print($i."<BR>");
flush();
sleep(1);
}
?>
flush — Flush the output buffer
ob_clean — Clean (erase) the output buffer
ob_end_clean — Clean (erase) the output buffer and turn off output buffering
ob_end_flush — Flush (send) the output buffer and turn off output buffering
ob_flush — Flush (send) the output buffer
ob_get_contents — Return the contents of the output buffer
ob_get_length — Return the length of the output buffer
ob_get_level — Return the nesting level of the output buffering mechanism
ob_gzhandler — ob_start callback function to gzip output buffer
ob_implicit_flush — Turn implicit flush on/off
ob_start — Turn on output buffering