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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
46 + 41 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 01:01:28 2024 UTC