Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
sleep()
I am using the php function sleep() but it does not work the way I expect it to...
I am expecting it to pause for 1 second between every line but it actually pauses for 3 seconds then spits out all three lines at once.
echo "This is guff A";
sleep(1);
echo "This is guff B";
sleep(1);
echo "This is guff C";
sleep(1);
I am expecting it to pause for 1 second between every line but it actually pauses for 3 seconds then spits out all three lines at once.
Posted: Sunday, 6 May 2007 at 10:37AM
0
This discussion has been closed.
Comments
I would have expected the script to work in the way you thought when run from the command line.
All the places it can be delayed (could be more):
1. At the server, within PHP. Output buffering prevents transmission until the script is finished.
2. At the server. Apache or whatever holds a buffer waiting for its size to exceed before sending a HTTP/TCP/IP packet.
3. At the server. Mod_gzip doesn't truely compress a page on the fly, but waits until it has the whole page before compressing it.
4. At an intermediary proxy, for the same reasons as above.
5. At the browser's renderer. Netscape is famous for delaying rendering of a table until its close tag appears. Some versions of IE render 256 bytes at a time.
I've tried everything listed here and still couldn't get the desired results.
It's actually not the delay that's the problem it's the lack of it!
In any case, it's a cosmetic thing as far as my requirement goes.
Thanks for all the suggestions.
Posted: Sunday, 6 May 2007 at 4:59PM