A "loading..." message while some PHP is being executed?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anon_amos
Forum Newbie
Posts: 1
Joined: Fri Apr 17, 2009 6:09 am

A "loading..." message while some PHP is being executed?

Post by anon_amos »

I have a chunk of php code that may take some time to run.

Before I execute this, I want a short message saying "Loading..." or something similar.

However, it seems that my PHP isn't being executed at runtime, so if I echo this message before the chunk of php, it doesn't show up, and the user is left looking at a blank page until the script is finished.

How do I get around this?

help appreciated.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: A "loading..." message while some PHP is being executed?

Post by Eran »

There is a way to do this, by flushing the output buffer before you start the heavy lifting -http://www.php.net/manual/en/function.flush.php
Read the fine print in the manual - you might need to use both flush() and ob_flush() depending on your server software, and gzipping can interfere as well.
Post Reply