how to show script output while running (ob_flush stuff)

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
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

how to show script output while running (ob_flush stuff)

Post by jmut »

Ok
I am really having problem with this stuff :(

I want to display echos for example while running an foreach.
having sleep for example to actually see that the flush is working.
10x

Code: Select all

ob_start();

echo "Hello ";

$out1 = ob_get_contents();
sleep(2);
echo "World";

$out2 = ob_get_contents();

ob_end_clean();

var_dump($out1, $out2);
how could I make this script show me "Hello"
and after 2 seconds "World".


Thanks a lot
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I word to the wise: some servers, or server settings, may affect your output buffering. flush() and ob_flush() may work just fine on the php side, but it still may be buffered on the actual server's side.
Post Reply