(PHP 5, PHP 7)
time_nanosleep — 锟接伙拷执锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
锟斤拷锟斤拷锟接伙拷执锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷 seconds
锟斤拷 nanoseconds
锟斤拷
seconds
锟斤拷锟斤拷锟斤拷一锟斤拷锟角革拷锟斤拷锟斤拷锟斤拷
nanoseconds
锟斤拷锟斤拷锟斤拷一锟斤拷小锟斤拷1锟节的非革拷锟斤拷锟斤拷锟斤拷
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
锟斤拷锟斤拷映俦锟斤拷卸希锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟结返锟截o拷锟斤拷锟斤拷为锟斤拷
锟芥本 | 说锟斤拷 |
---|---|
5.3.0 | 锟斤拷锟斤拷之锟斤拷煤锟斤拷锟斤拷锟絎indows平台锟铰匡拷锟矫★拷 |
Example #1 time_nanosleep() 锟斤拷锟斤拷锟斤拷
<?php
// Careful! This won't work as expected if an array is returned
if (time_nanosleep(0, 500000000)) {
echo "Slept for half a second.\n";
}
// This is better:
if (time_nanosleep(0, 500000000) === true) {
echo "Slept for half a second.\n";
}
// And this is the best:
$nano = time_nanosleep(2, 100000);
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.";
}
?>