|  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.
Block user comment
Status: Assign to:
Bug Type:
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	
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-2023 The PHP Group
All rights reserved.
Last updated: Mon Sep 25 04:01:25 2023 UTC