#50039 [Opn]: example code at time_sleep_until-function is IMHO wrong
| From: | ingo at baab dot de | Date: | Fri, 30 Oct 2009 11:21:52 +0000 |
| Subject: | #50039 [Opn]: example code at time_sleep_until-function is IMHO wrong | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3023@lists.php.net to get a copy of this message | ||
ID: 50039
User updated by: ingo at baab dot de
Reported By: ingo at baab dot de
Status: Open
Bug Type: Documentation problem
Operating System: All
PHP Version: Irrelevant
New Comment:
correction: use microtime(true); instead
Previous Comments:
------------------------------------------------------------------------
[2009-10-30 11:18:40] ingo at baab dot de
Description:
------------
The example in the documentation is IMHO wrong.
time_sleep_until() wants a timestamp as float,
but the example shows getting a value from time().
Here should be used microtime(true) to get a
float value. The shown example will only work
accidentally right (without a warning), if
(time()+0.2) is not allready in the past when
generated. Use microtime() instead here.
Reproduce code:
---------------
---
From manual page: function.time-sleep-until#Beispiele
---
<?php
// Gibt false zurück und generiert eine Warnung
var_dump(time_sleep_until(time()-1));
// funktioniert evtl. nur auf schnellen Rechnern, schläft für bis zu
0.2 Sekunden
var_dump(time_sleep_until(time()+0.2));
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50039&edit=1