Send real-time php script status to web browser

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
auroch
Forum Newbie
Posts: 1
Joined: Wed Jan 04, 2006 9:34 am

Send real-time php script status to web browser

Post by auroch »

Hi,


I'd like to find a simple way to follow execution of a php script in "real time".

Actually, when I call a php script from a web page, the script is executed by the server, and the result of the script is displayed at the end of its execution (by the mean of "print" statements).

I'm working on big scripts taking a lot of time.
I would like to output some information to the web browser before reaching the end of the script, and if possible update information in "real-time", from the start of the script to the end of the script.

What is the correct mean to achieve this ?

Is there a simple mean to do that, playing with HTML headers (Flush()) ?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

I'm not sure the specifics of your question but yes, you can do this using AJAX.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Look at my posts here viewtopic.php?t=12436&highlight=sleep

The code is a bit broken cos of the forum crash a while ago :cry:
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: Send real-time php script status to web browser

Post by Roja »

auroch wrote:Hi,


I'd like to find a simple way to follow execution of a php script in "real time".

Actually, when I call a php script from a web page, the script is executed by the server, and the result of the script is displayed at the end of its execution (by the mean of "print" statements).
Thats not accurate.

If you do NOT use output buffering, the result is printed as it proceeds - not at the end of the script.

auroch wrote: I'm working on big scripts taking a lot of time.
I would like to output some information to the web browser before reaching the end of the script, and if possible update information in "real-time", from the start of the script to the end of the script.

What is the correct mean to achieve this ?

Is there a simple mean to do that, playing with HTML headers (Flush()) ?
And yes, if you want to make absolutely, totally sure, you can do a flush. :)
Post Reply