have php make server wait/pause/count

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

have php make server wait/pause/count

Post by afbase »

Is there a way in php to make the server count/wait/pause for a given time period? For instance

Code: Select all

while ($red = "wings for life"){
/*  stuff done here */

count_time(5); //<---- that line makes php/server count 5 seconds before continuing with the script

}
Is there something like this????
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

quicky

Post by afbase »

I made this script kinda on the fly. Does anyone see anything wrong with it? It runs fine for me but it just feels really shoddy:

Code: Select all

function time_diff($time_to_wait){
			$now = time();
			print date("m-d-Y G:i-s",$now);
			for($i=0; $i <= $i+1;$i++){
				$future = $now + $time_to_wait;
				if (time() == $future) break;
				$i=0;
			}
			print date("m-d-Y G:i-s",$future);
		  }
does anyone have a better idea that feels more kosher than this?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Post by afbase »

friggin sweet


Burrito++;
arukomp
Forum Contributor
Posts: 113
Joined: Sun Sep 24, 2006 4:22 am

Post by arukomp »

Also you can use usleep() to wait for microseconds
Post Reply