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()

edited May 2007 in Vanilla 1.0 Help
I am using the php function sleep() but it does not work the way I expect it to...

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

Comments

  • it problem depends on your php setup and how it caches output.

    I would have expected the script to work in the way you thought when run from the command line.
  • I've heard you have to do things like ob_flush(); and flush(); to get the output, as well as outputting additional "filler" information to get around all the caching that happens between the server and the screen.

    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.
  • I came to pretty much the same conclusion, surely there is a "wait" function that will do the job?

    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

This discussion has been closed.