php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53873 Bug in rand()
Submitted: 2011-01-28 22:26 UTC Modified: 2011-01-28 22:36 UTC
From: noel_fb at hotmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.5 OS: Linux
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: noel_fb at hotmail dot com
New email:
PHP Version: OS:

 

 [2011-01-28 22:26 UTC] noel_fb at hotmail dot com
Description:
------------
$codigo = rand(100,4294967295);
El valor de $CODIGO fue: 81
-----------------------------
$codigo = rand(100,4294967295);
the value of $CODIGO is: 81

---
From manual page: http://www.php.net/function.rand#Descripción
---

Test script:
---------------
$codigo = rand(100,4294967295);
El valor de $CODIGO fue: 81
-----------------------------
$codigo = rand(100,4294967295);
the value of $CODIGO is: 81


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-28 22:36 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-01-28 22:36 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is because the 4294967295 is converted to long, hence...
var_dump((int)4294967295); // int(-1)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 28 17:00:02 2025 UTC