php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11108 Problem in rand() on win2000 (or all win32?)
Submitted: 2001-05-25 04:02 UTC Modified: 2001-07-22 15:55 UTC
From: djewett at usd dot edu Assigned:
Status: Closed Package: Math related
PHP Version: 4.0.5 OS: Windows 2000 SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: djewett at usd dot edu
New email:
PHP Version: OS:

 

 [2001-05-25 04:02 UTC] djewett at usd dot edu
// Sample code for problem	
srand(time());
for($counter = 0; $counter<= 20 ; $counter++){
print(rand(0,5 );
print("<br>");
}

for some reason this always returns the same number as the first number returned, until the file is modified.  The first number, after that, the numbers seem to be random.  

I'm using the latest apache & php on a win2k SP2 laptop

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-22 15:55 UTC] andy@php.net
try using a better seed for the random number, such as

srand((double) microtime() * 1000000);

this fixed the problem on my machine.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Nov 29 15:03:13 2021 UTC