Page 1 of 1

real time Output from php to Browser

Posted: Mon Jan 13, 2003 3:39 am
by mei
I need real time otput from php to Browser....

For example: first i print on Screen HTML content... then i need register transaction and output on Screen registration-status....

But that don't works.... first register transaction and then pript on Screen HTML content and registration-status in one time....

Soory, if all not understand.... but i speek english very bad....

P.S. maby i need change some configuration in Apache or PHP

Posted: Mon Jan 13, 2003 4:03 am
by volka
maybe I missed the point. Do you want to asure that partial results of your script are sent to the browser before the script's execution continues?
If so, flush() is your best chance.
http://www.php.net/manual/en/function.flush.php

Posted: Mon Jan 13, 2003 4:12 am
by mei
Flush() don't work exactly.... how i understand in manual.... Flush don't works with browsers output....

example:

echo "first output\n";
flush();
sleep(10);
esho "second output\n";

line "first output" show on browser after 10 sec. with "second output";

Posted: Mon Jan 13, 2003 4:22 am
by volka
nope, all the manual says is: maybe it works, maybe not, depending on your webserver's and the client's configuration. It's still your best chance and worth a try ;)
e.g. my mozilla browser displays the first string long before sleep(10) is finished, while internet explorer refuses to display anything until the script is done :-S
But with

Code: Select all

<html><body><pre><?php
echo "first output\n";
flush();
sleep(10);
echo "second output\n"; 
?></pre></body></html>
both browsers handle the partial data as expected :D

Posted: Mon Jan 13, 2003 9:06 am
by mei
my browsers:
Mozilla/5.0- Don't work
IE 5.5 - Don't work
Netscape Comunicator 4.7 - Don't work

Maby need something change in webserver configuration.... but i don't know- what.... :(

Posted: Mon Jan 13, 2003 9:40 am
by volka
may also be that your script outputs something that browsers do not render immediately. Part of a table that is not fixed-size e.g. or parts of a <div> that has a relative position but no width-property or ... or ...
Try to encapsulate your output in a <p>...</p>-Block with no further styles before calling flush();