Re: Output text status on a long class

From: Date: Tue, 14 Oct 2008 15:22:28 +0000
Subject: Re: Output text status on a long class
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-281889@lists.php.net to get a copy of this message
Stut wrote:
On 14 Oct 2008, at 15:56, Chrome wrote:
I have a class that takes a while to run and am wanting to push some output to the browser while it's doing its stuff. Is that possible? Here's what I'd like: Connecting to server... Done! Retrieving categories... Done! ... All I can get it to do is output all of the text at the end of the script A voice in my head says that outputting all of the text at the end of the script is the only way to do it. Then another voice says but there must be a way! :) I did try a quick test of buffering the text then explicitly flushing the buffer but it didn't seem to work I know this seems pointless but I'm anticipating that the users will be confused (which would be a surprise </sarcasm>) and attempt to abort/bugger off somewhere else
Put this line at the top of your script... while (@ob_end_clean()); That will remove any output buffers and your script should then output stuff as it happens. -Stut
Or you could add flush(); after your output, which will flush the output buffer and force it to display. Jay

« previous php.general (#281889) next »