time delay in php

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
PaulK
-


Joined: 26 Apr 2006
Posts: 132
Location: London, UK

PostPosted: Fri Oct 06, 2006 2:52 pm    Post subject: time delay in php Reply with quote

Is there a command for making php wait for set number ot seconds/minutes?

I tried php.net and did a scan for wait and puase as commands but couldnt find aything useful.

Thanks guys
Paul
Back to top View user's profile Send private message Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Fri Oct 06, 2006 3:01 pm    Post subject: Reply with quote

Use sleep() to make it stop for N seconds. Use usleep() to make it stop for N milliseconds.

Code:

<?php

//Sleep for three seconds
sleep(3);

//Sleep another three seconds
usleep(3000000);

//Try outputting some data
echo "Hello ";

//Send the text to the client
flush();
ob_flush();
sleep(2);

//Output "world!" two seconds after "hello".
echo "world!";
?>
Back to top View user's profile Send private message
PaulK
-


Joined: 26 Apr 2006
Posts: 132
Location: London, UK

PostPosted: Fri Oct 06, 2006 3:29 pm    Post subject: Reply with quote

ahhh sleep!!! *slaps forehead* thank you, just want I was after!

Paul
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group