php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6330 rand() and mt_rand() caches their result
Submitted: 2000-08-24 06:40 UTC Modified: 2000-08-24 06:42 UTC
From: dave at arthistory dot cc Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.0 OS: RHL 6.1 and RHL 6.2
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: dave at arthistory dot cc
New email:
PHP Version: OS:

 

 [2000-08-24 06:40 UTC] dave at arthistory dot cc
Hi,

I have experienced real troubles with rand() and mt_rand().
It seems to cache the result from previously execution. My function seems to generate the same random-numbers annoyinly often... I think it's quite weird that both random function so often generates the same values between a given range!

I'm not that experienced with PHP, but I do know for sure that it's not my scriptingcode that's messy... I would be glad to help! 
-------MORE INFO---------
Code: www.arthistory.cc/rand.txt
Script: www.arthistory.cc/html2/fantasy_main.php
php-info: www.arthistory.cc/info.php

Best Regards Dave

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-24 06:42 UTC] stas@php.net
You should use srand before using rand.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 12:01:32 2024 UTC