Page 1 of 1

Send real-time php script status to web browser

Posted: Wed Jan 04, 2006 10:10 am
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()) ?

Posted: Wed Jan 04, 2006 10:22 am
by hawleyjr
I'm not sure the specifics of your question but yes, you can do this using AJAX.

Posted: Wed Jan 04, 2006 11:16 am
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:

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

Posted: Wed Jan 04, 2006 7:39 pm
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. :)