php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1857 rand() produces values outside a specified range
Submitted: 1999-07-23 19:56 UTC Modified: 1999-07-23 22:31 UTC
From: andrew at walcat dot ac dot uk Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0 Beta 1 OS: RH6
Private report: No CVE-ID: None
 [1999-07-23 19:56 UTC] andrew at walcat dot ac dot uk
Hello,

This error seems to be exactly like the one present in 3.0.6, rand() generates values outside the given range. I have run the following code many times and get numbers well above 122, and numbers below 97 too.

<?
srand((double)microtime()*1000000);
$rand = rand(97,122);
echo($rand);
?>

Regards,
Andy Pitt.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-07-23 22:31 UTC] rasmus at cvs dot php dot net
Fixed in CVS
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 10:00:01 2026 UTC