I use a common function to "print" messages to the browser window like this:
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
function showProgressMsg($msg)
{
$h = date('H');
echo $msg.": ".$h.":".date('i').":".date('s')."<br>";
ob_flush();
flush();
usleep(25000);
}
ini_set('output_buffering', 'Off');// delete the 4096k value
ob_implicit_flush(true);
$h = date('H');
echo "Beginning import at: ".$h.":".date('i')."\n<br>";
ob_start ();
$x=0;
// Do something
while($x < 100) {
$x++;
showProgressMsg("Doing something.<br>");
}
$x=0;
// Do something else
while($x < 100) {
$x++;
showProgressMsg("Doing something else.<br>");
}
ob_end_clean();
ini_set('display_errors', 0);
ini_set('max_execution_time', 360);
ini_set('output_buffering', 4096);
$h = date('H');
echo "Ended import at: ".$h.":".date('i')."\n<br>";
?>
</body>
</html>
But for some reason, when I run this on localhost, it waits until it is complete before outputting anything to the browser.
If I run it online, it does exactly like I'd expect.
Any ideas?