PHP缓冲区强制及时输出

时间:2021-06-12 21:30:06
string '{"multicast_id":4917012850725514945,"success":0,"failure":38,"canonical_ids":0,"results":[{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"Mismat'... (length=1193)
string '{"multicast_id":4917012850725514945,"success":0,"failure":38,"canonical_ids":0,"results":[{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"MismatchSenderId"},{"error":"Mismat'... (length=1193)
<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);
// usleep(100000);
}
?>