View Single Post
  #4 (permalink)  
Old 10-17-2008, 11:06 AM
wige's Avatar
wige wige is online now
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,661
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: PHP output while script is running

I have a PHP script that has to cycle through XML feeds containing hundreds of thousands of elements once a month. I use the same basic methodology you are looking for where it outputs a '.' each time it processes an XML element so I know the script hasn't died. The basic code is the following:

echo '. ';
if ($a % 10 == 0) {
ob_flush();
flush();
}

You can remove the if and closing brace lines so it will force output to the browser after each individual '.'. In my case, outputing the dots in groups of ten is sufficient.

In my case, AJAX calls wouldn't work because the script needs to also be executed by the operating system and by wget and cron.
__________________
The best way to learn anything, is to question everything.
Reply With Quote