Page 1 of 1

flush problems

Posted: Fri Aug 06, 2010 5:36 pm
by shawngoldw
Very simply, I can not get flush to work. I'm using this code:

Code: Select all

for ($i=0; $i < 3; $i++) 
{ 
	echo $i;
	flush();
	sleep(1);
}
I've tried with ob_flush() too but can't get that working. I know that the server is set up to allow it because if I run this:

Code: Select all

phpinfo();
for ($i=0; $i < 3; $i++) 
{ 
	echo $i;
	flush();
	sleep(1);
}
phpinfo flushes and then my loop does not. How do I use flush properly?


Thank you,
Shawn

Re: flush problems

Posted: Fri Aug 06, 2010 6:02 pm
by JakeJ
shawngoldw wrote: How do I use flush properly?
Sometimes you have to hold the handle down until all the water is gone.

Hey! It's Friday night! What do you want from me? Sanity and clear thinking?

Re: flush problems

Posted: Fri Aug 06, 2010 7:12 pm
by shawngoldw
JakeJ wrote:
shawngoldw wrote: How do I use flush properly?
Sometimes you have to hold the handle down until all the water is gone.

Hey! It's Friday night! What do you want from me? Sanity and clear thinking?
haha, too bad I'm stuck in a university town during exams!


It seems that adding

Code: Select all

print str_pad("",5000)."<br>\n";
before flush makes it work....
Whaaa?

Re: flush problems

Posted: Sat Aug 07, 2010 9:40 am
by McInfo
Read the description for flush(). One or more of the situations described may apply to you.

Re: flush problems

Posted: Sat Aug 07, 2010 11:32 am
by shawngoldw
Thanks, I've read through a lot of that already, thats how I got it to work with the pad. I think it has to do with the output_buffer which is set to 4096 bytes. I'll work it out