php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50039 example code at time_sleep_until-function is IMHO wrong
Submitted: 2009-10-30 11:18 UTC Modified: 2009-11-02 10:59 UTC
From: ingo at baab dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ingo at baab dot de
New email:
PHP Version: OS:

 

 [2009-10-30 11:18 UTC] 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));

?>




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-30 11:21 UTC] ingo at baab dot de
correction: use microtime(true); instead
 [2009-11-02 10:59 UTC] 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-11-02 10:59 UTC] rquadling@php.net
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.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 15:00:02 2026 UTC