#50039 [Opn->Csd]: example code at time_sleep_until-function is IMHO wrong

From: Date: Mon, 02 Nov 2009 10:59:34 +0000
Subject: #50039 [Opn->Csd]: 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-3032@lists.php.net to get a copy of this message
ID: 50039 Updated by: rquadling@php.net Reported By: ingo at baab dot de -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: All PHP Version: Irrelevant New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2009-11-02 10:59:27] svn@php.net Automatic comment from SVN on behalf of rquadling Revision: http://svn.php.net/viewvc/?view=revision&revision=290143 Log: Fix example to reflect a float time for time-sleep-until. Fix bug#50039 ------------------------------------------------------------------------ [2009-10-30 11:21:52] ingo at baab dot de correction: use microtime(true); instead ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#3032) next »