you may use the flush() function to attempt to flush data back to the browser.
description from php.net:
Flushes the write buffers of PHP and whatever backend PHP is using
(CGI, a web server, etc). This attempts to push current output all the
way to the browser with a few caveats.
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.
sample code below, tested on chrome 31.0.1650.57 (linux), Safari (6.0.4) (osx):
note: whether or not to show the flushed output is up to the browser (usually depending on the amount of data in the response). for example Safari (6.0.4) wants 512 bytes of data before outputting data to the browser. You can get around this by doing something like padding 512 characters to beginning of the output.
<?php
header( 'Content-type: text/html; charset=utf-8' );
echo str_repeat(" ",512); //pad the buffer with data (in case browser needs it)
while (true){
//write go to the browser every 2 seconds.. forever
echo "go...<br/>";
ob_flush();
flush();
sleep(2);
}
?>
more info here http://us1.php.net/manual/en/function.flush.php