php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #9823 srand() -- seed should default to (double)microtime()*1000000
Submitted: 2001-03-18 16:25 UTC Modified: 2002-04-27 15:08 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ryland at ryland dot net Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS: all
Private report: No CVE-ID: None
 [2001-03-18 16:25 UTC] ryland at ryland dot net
In the user notes for srand(), richard@zend.com said:

>*ALWAYS* use (double)microtime()*1000000 as your seed. 
>Do *NOT* just use time(). Do not add an extra 0 to make it "bigger". 
...
>Anything else is sub-standard.

If so, why not make the seed argument optional, and make the default
(double)microtime()*1000000 when the argument is absent? Save me a
few keystrokes, anyway, and help make sure people don't do it in a 
"sub-standard" fashion...  :)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-27 15:08 UTC] jimw@php.net
the seed is optional and php generates a 'good' one.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 20:01:37 2024 UTC