I have this code:
set_time_limit(0);
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
ob_flush();
flush();
$start = time();
$secs = time() - $start;
while ($secs <= 300)
{
echo "this script has been running for $secs seconds.\n";
ob_flush();
flush();
sleep(1);
}
What I'd like to do when I view this page, is to see in real time how long the script has been running, like this:
- Script has been running 1 seconds.
- Script has been running 2 seconds.
- ............
- Script has been running 300 seconds.
Instead what I get is a blank window with a continuous 'loading' sign for 5 minutes, and after 5 mins suddenly i'm bombarded with a load of these messages which i should've been getting 1 message at a time.
Can someone explain what I'm doing wrong?