Page 1 of 1

Pause a series of messages

Posted: Thu Sep 05, 2002 7:42 pm
by Stoyanski
Hi to all,
I want to print (echo) some messages (3 for example) separated by 2 seconds. This can not be done in PHP, so I think JS is the solution.

Posted: Thu Sep 05, 2002 9:01 pm
by jason
well, technically, you can.

http://www.php.net/sleep

Posted: Thu Sep 05, 2002 9:05 pm
by hob_goblin

Code: Select all

<?
echo '1...';
sleep(1);
echo '2...';
sleep(1);
echo '3!';
?>

Posted: Thu Sep 05, 2002 10:15 pm
by volka
if using this you should flush the output-buffer befor sleep() to be on the safe side.
i.e. ob_flush()
in addition here's a quote from the user contributed notes of sleep()
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!