Can PHP output text 'during' program execution?
Example: the following code will not output a line to a web browser every three seconds as you would think...instead, it waits until the 'entire program has executed' and then outputs all the lines at once.
<?
print "start program<br>\n";
sleep(3);
print "three seconds past...still going<br>\n";
sleep(3);
print "three seconds past...still going<br>\n";
sleep(3);
print "three seconds past...end program<br>\n";
?>
The reason I ask is that I have an application that requres several minutes to complete it's tasks. It takes so long that my browser times out before the program can finish. It is a broadcast email program that basically does...
while (still emails to process) {
mail(address, subject, etc);
}
Even at 1/2 second per email, the program takes more time than my browser will wait. I have tried outputing status messages during the process but...as you will see if you try the snippet above...'nothing' gets sent to the browser until the 'entire' program completes.
Is there a way in PHP to send output 'during' program execution? If not, has anyone seen any work arounds for a problem like this?
Any help would be appreciated.
chuckc