Doc #74246 [NEW]: Clarify that although rand() is an alias for mt_rand() it has BC differences
| From: | peehaa@php.net | Date: | Tue, 14 Mar 2017 13:22:45 +0000 |
| Subject: | Doc #74246 [NEW]: Clarify that although rand() is an alias for mt_rand() it has BC differences | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-14503@lists.php.net to get a copy of this message | ||
From: peehaa
Operating system:
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Clarify that although rand() is an alias for mt_rand() it has BC differences
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.
--
Edit bug report at https://bugs.php.net/bug.php?id=74246&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74246&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74246&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74246&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74246&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74246&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74246&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74246&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74246&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74246&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74246&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74246&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74246&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74246&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74246&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74246&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74246&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74246&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74246&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74246&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74246&r=mysqlcfg