Doc #60559 [NEW]: mt_rand() backward incompatibility

From: Date: Mon, 19 Dec 2011 10:31:29 +0000
Subject: Doc #60559 [NEW]: mt_rand() backward incompatibility
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7682@lists.php.net to get a copy of this message
From:             
Operating system: Linux
PHP version:      5.3.8
Package:          *Math Functions
Bug Type:         Documentation Problem
Bug description:mt_rand() backward incompatibility

Description:
------------
---
From manual page: http://www.php.net/migration53.incompatible
---
It looks like in PHP 5.2 mt_rand($a, $b) returned the value from the range
between $a and $b. There was no the requirement that $b must be greater
than $a (checked on PHP 5.2.17).

In PHP 5.3.8 the warning is triggered and boolean false is returned if
second parameter is less than the first.

[19-Dec-2011 11:26:47] PHP Warning:  mt_rand(): max(2) is smaller than
min(5) in /mnt/hgfs/data/ciao-php/ciao/test.php on line 6

I haven't noticed this incompatibility in the backward incompatible changes
list.

Test script:
---------------
<?php

for ($i = 0; $i < 5; $i++) {
    var_dump(mt_rand(160, 0)); 
    echo "\n";
}


-- 
Edit bug report at https://bugs.php.net/bug.php?id=60559&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=60559&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=60559&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=60559&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=60559&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60559&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=60559&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=60559&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=60559&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=60559&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=60559&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=60559&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=60559&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=60559&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=60559&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=60559&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60559&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=60559&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=60559&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=60559&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=60559&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=60559&r=mysqlcfg



Thread (3 messages)

« previous php.doc.bugs (#7682) next »