output as page goes along, 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
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

output as page goes along, not all at once

Post by toms100 »

hmm
basically, i want to make my script send its output as it is printed, not all at once, once the whole page has been generated.
ie

Code: Select all

<?php
echo "1";
/// some stuff here which takes, say 10 seconds to compute
echo "2";
/// more stuff
echo "3";
// etc etc

?>
i want the script to first print 1, then in 10 seconds time print 2, etc etc.
is this possible?

maybe it can be done wiht output buffering, but im not sure :s
hope somoene can help!
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try http://php.net/flush , but be sure to read the user comments for the various 'quirks'.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I needed to do this for a bill creation application I was making. I found that using ob_implicit_flush('1'), would dump the page as it was created, and ob_implicit_flush('0') would turn buffering back on.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply