PHP中刷新输出缓冲,立即输出数据
<script type="text/javascript"> function show_message(message) { document.getElementById('notice').innerHTML += message + '<br />'; document.getElementById('notice').scrollTop = 100000000; } </script> <div id="notice" style="width:950px; height: 200px; overflow:scroll; word-break: break-all; word-wrap:break-word;"></div> <?php //echo str_pad(" ", 256); echo str_pad(" ", 1000); // 保证缓冲区数量 function showjsmessage($message) { echo '<script type="text/javascript">show_message(\''.addslashes($message).' \');</script>'."\r\n"; flush(); ob_flush(); } for ($i=0; $i < 100; $i++) { showjsmessage($i); sleep(1); } ?>