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
 [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: Thu Mar 28 18:01:29 2024 UTC