RE: [PHP] Output text status on a long class
| From: | Chrome | Date: | Tue, 14 Oct 2008 15:30:58 +0000 |
| Subject: | RE: [PHP] Output text status on a long class | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281893@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.
I did that as well as stut's suggestion. And I tried ob_flush() (just in
case). Tried a few combinations
Personally I think I sometimes have a negative effect on these things
Dan
> Jay
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php