time_nanosleep

(PHP 5, PHP 7)

time_nanosleep锟接伙拷执锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�

说锟斤拷

time_nanosleep ( int $seconds , int $nanoseconds ) : mixed

锟斤拷锟斤拷锟接伙拷执锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷 seconds 锟斤拷 nanoseconds锟斤拷

锟斤拷锟斤拷

seconds

锟斤拷锟斤拷锟斤拷一锟斤拷锟角革拷锟斤拷锟斤拷锟斤拷

nanoseconds

锟斤拷锟斤拷锟斤拷一锟斤拷小锟斤拷1锟节的非革拷锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟缴癸拷时锟斤拷锟斤拷 TRUE锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE锟斤拷

锟斤拷锟斤拷映俦锟斤拷卸希锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟结返锟截o拷锟斤拷锟斤拷为锟斤拷

  • seconds - 锟接筹拷剩锟斤拷未执锟叫碉拷锟斤拷锟斤拷
  • nanoseconds - 锟接筹拷剩锟斤拷未执锟叫碉拷锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
5.3.0 锟斤拷锟斤拷之锟斤拷煤锟斤拷锟斤拷锟絎indows平台锟铰匡拷锟矫★拷

锟斤拷锟斤拷

Example #1 time_nanosleep() 锟斤拷锟斤拷锟斤拷

<?php
// Careful! This won't work as expected if an array is returned
if (time_nanosleep(0500000000)) {
    echo 
"Slept for half a second.\n";
}

// This is better:
if (time_nanosleep(0500000000) === true) {
    echo 
"Slept for half a second.\n";
}

// And this is the best:
$nano time_nanosleep(2100000);

if (
$nano === true) {
    echo 
"Slept for 2 seconds, 100 microseconds.\n";
} elseif (
$nano === false) {
    echo 
"Sleeping failed.\n";
} elseif (
is_array($nano)) {
    
$seconds $nano['seconds'];
    
$nanoseconds $nano['nanoseconds'];
    echo 
"Interrupted by a signal.\n";
    echo 
"Time remaining: $seconds seconds, $nanoseconds nanoseconds.";
}
?>

锟轿硷拷

  • sleep() - 锟接伙拷执锟斤拷
  • usleep() - 锟斤拷指锟斤拷锟斤拷微锟斤拷锟斤拷锟接筹拷执锟斤拷
  • time_sleep_until() - 使锟脚憋拷睡锟竭碉拷指锟斤拷锟斤拷时锟斤拷为止锟斤拷
  • set_time_limit() - 锟斤拷锟矫脚憋拷锟斤拷锟街达拷锟绞憋拷锟�