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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ryland at ryland dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Sep 20 11:00:01 2025 UTC