Announcement

Collapse
No announcement yet.

Delay between statements.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Xelopheris
    replied
    Why exactly would you want the statement to be delayed? Most often, browsers take a rusty chainsaw to pages with incomplete HTML. However, if you do, remember to flush() before you sleep().

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Originally posted by Icheb
    Just let the script sleep .

    "Maybe it's not possible in PHP. Isn't php first parsing the whole script and then at the end produces the page to be sent to the webbrowser? If this is so, then it's not possible to let it echo 1 statement, wait 1 sec and then put out the second one."

    PHP sends the data when it's created, not when the page is finished.
    From the comments on the function.sleep page at php.net

    hartmut at six dot de
    25-Aug-2000 07:38
    it is a bad idea to use sleep() for delayed output effects as

    1) you have to flush() output before you sleep

    2) depending on your setup flush() will not work all the way to the browser as the web server might apply buffering of its own or the browser might not render output it thinks not to be complete

    netscape for example will only display complete lines and will not show table parts until the </table> tag arrived

    so use sleep if you have to wait for events and don't want to burn to much cycles, but don't use it for silly delayed output effects!

    Leave a comment:


  • Icheb
    replied
    Just let the script sleep .

    "Maybe it's not possible in PHP. Isn't php first parsing the whole script and then at the end produces the page to be sent to the webbrowser? If this is so, then it's not possible to let it echo 1 statement, wait 1 sec and then put out the second one."

    PHP sends the data when it's created, not when the page is finished.

    Leave a comment:


  • marocnl
    replied
    Originally posted by xiphoid
    Maybe with exec(sleep 1); ?
    I don't know.

    Maybe it's not possible in PHP. Isn't php first parsing the whole script and then at the end produces the page to be sent to the webbrowser? If this is so, then it's not possible to let it echo 1 statement, wait 1 sec and then put out the second one.

    Leave a comment:


  • Floris
    replied
    Maybe with exec(sleep 1); ?

    Leave a comment:


  • marocnl
    started a topic Delay between statements.

    Delay between statements.

    Does anybody know how to do the following:

    <?php

    echo "Bla1";

    --wait 1 sec.--

    echo "$Bla2";

    ?>

    What do i use to have the delay between the echo-statements. The first statement has to show up on the page and then the second one should show up after 1 sec.
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X