|  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
 [2001-05-25 04:02 UTC] djewett at usd dot edu
// Sample code for problem	
for($counter = 0; $counter<= 20 ; $counter++){
print(rand(0,5 );

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-22 15:55 UTC]
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: Mon Feb 26 12:01:26 2024 UTC