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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-24 06:42 UTC] stas@php.net
You should use srand before using rand.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 22:00:01 2026 UTC