php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74246 Clarify that although rand() is an alias for mt_rand() it has BC differences
Submitted: 2017-03-14 13:22 UTC Modified: 2017-04-03 14:57 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: peehaa@php.net Assigned: peehaa (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: peehaa@php.net
New email:
PHP Version: OS:

 

 [2017-03-14 13:22 UTC] peehaa@php.net
Description:
------------
As of 7.1 rand() is mostly an alias of mt_rand.

This is explained in the doc notes http://php.net/manual/en/function.rand.php.

However it does have some difference to preserve BC.

See also the user note @ http://php.net/manual/en/function.rand.php#120782:

From PHP 7.1 rand() is documented as an alias of mt_rand().

Actually, if they are called with two arguments where the second is smaller than the first, their output differs.

For example

var_dump(rand(2,1), mt_rand(2,1));

may return

Warning: mt_rand(): max(1) is smaller than min(2)
int(2)
bool(false)

where rand() will return a random value between $max and $min


Expected result:
----------------
Clarify taht rand() isn't an exact alias.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-14 13:23 UTC] peehaa@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: peehaa
 [2017-04-03 14:57 UTC] peehaa@php.net
-Status: Verified +Status: Closed
 [2017-04-03 14:57 UTC] peehaa@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 05:01:30 2024 UTC