HTML output in parts not all at once ?

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
Kari
Forum Newbie
Posts: 3
Joined: Thu Apr 24, 2003 9:01 am

HTML output in parts not all at once ?

Post by Kari »

Hi All,
Php is processing and buffering all html before output, I think...
Is it possible to output html in parts ? Like:
function1 sends html head & body tags
function2 sends character '*'
function3 does something, 1 sec. delay for example
now
function2 sends charcter '*' again but so that it is
added after previous charcter 1 sec later,
function4 sends closing tags
I have tried this with loops but what happens is that all
code is processed and html is output at once.
I would like page to show current php script run status
in ' realtime ' like ' Reading file 1 ' after it is read script
adds to page ' Processing file 1 ' and so on, hope you
understand what I mean.

Thanks,
Kari
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Try the php command flush();
Kari
Forum Newbie
Posts: 3
Joined: Thu Apr 24, 2003 9:01 am

Post by Kari »

Inter,
Thank you very much! flush() was exactly
what I was looking for.
Php function list says win32 servers
and some other buffer html anyway.
Got it working on my Win98 home PC
( with Apache ) and Linux/Apache.
There was also good info about browser
buffers on php.net function list.

Thanks again,
Kari
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

You'r welcome.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

I am currently looking in the php manual for something on the flush function, but maybe someone can tell me what it is generally used for?
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

The output of php to the browser or a other program that's requesting your script, is bufferd.

To flush and send this buffer the flush command is called.

PHP does this automatic if the buffer is full, but you can allso set php to ignore flush or flush every thing you'r gonna output.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

php.net/any_function

will get you info about the particular function...eg...

http://www.php.net/flush
Post Reply