Pause a series of messages

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Stoyanski
Forum Newbie
Posts: 15
Joined: Sun Jun 02, 2002 9:33 am
Location: BG
Contact:

Pause a series of messages

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

well, technically, you can.

http://www.php.net/sleep
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Code: Select all

<?
echo '1...';
sleep(1);
echo '2...';
sleep(1);
echo '3!';
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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!
Post Reply