超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<unpackmnoGoSearch>
Last updated: Fri, 22 Jun 2007

usleep

(PHP 3, PHP 4 , PHP 5)

usleep -- Delay execution in microseconds

Description

void usleep ( int micro_seconds)

The usleep() function delays program execution for the given number of micro_seconds. A microsecond is one millionth of a second.

例子 1. usleep() example

<?php

// Current time
echo date('h:i:s') . "\n";

// wait for 2 secondes
usleep(2000000);

// back!
echo date('h:i:s') . "\n";

?>

This script will output :

11:13:28
11:13:30

注: This function did not work on Windows systems until PHP 5.0.0

See also sleep() and set_time_limit().




add a note add a note User Contributed Notes
usleep
beidson at calpoly dot edu
14-Sep-2000 02:18
Since USLEEP doesn't work under windows, you need to come up with your own fix.  This little function will do the trick.

function wait($usecs){
 $temp=gettimeofday();
$start=(int)$temp["usec"];
 while(1){
  $temp=gettimeofday();
   $stop=(int)$temp["usec"];
  if ($stop-$start >= $usecs) break;
 }
}

The smallest amount of time it seems to work with is around 200usecs, but if you wait() anything higher than 200usecs it's pretty close.

<unpackmnoGoSearch>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22