note 55166 added to function.time-nanosleep
| From: | tecnomaniac at ig dot com dot br | Date: | Tue, 26 Jul 2005 22:04:58 +0000 |
| Subject: | note 55166 added to function.time-nanosleep | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92514@lists.php.net to get a copy of this message | ||
This is an alternative function to sleep_nanosecond that you can use with PHP versions below PHP
5.0. It is not very accurate if we talk about nanoseconds but the results are satisfatory. Enjoy!
<?php
//THIS IS THE FUNCTION WE ARE TALKIN ABOUT
function timeWait($microtime)
{
$timeLimit = $microtime + array_sum(explode(" ",microtime()));
while(array_sum(explode(" ",microtime())) < $timeLimit)
{/*DO NOTHING*/}
return(true);
}
//THIS IS HOW WE CAN USE IT
echo "Process started at " . date("H:i:s") . " and " .
current(explode(" ",microtime())) . " nanoseconds.<br>";
timeWait(5.5); //With this call the system will wait 5 seconds and a half. You can use either
integer or float.
echo "Process completed at " . date("H:i:s") . " and " .
current(explode(" ",microtime())) . " nanoseconds.";
?>
----
Manual Page -- http://www.php.net/manual/en/function.time-nanosleep.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55166
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55166&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55166&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55166&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55166&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55166&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55166&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55166&report=yes
Search -- http://master.php.net/manage/user-notes.php