|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-12-19 10:31 UTC] kartyl at gmail dot com
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"; } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 06:00:01 2026 UTC |
It seems this Warning does not appear in PHP 5.3.3: Test script: ---------------- <?php echo PHP_VERSION . "\n"; error_reporting(-1); ini_set('display_errors', 1); for ($i = 0; $i < 5; $i++) { var_dump(mt_rand(160, 0)); echo "\n"; } ?> Result: --------------- 5.3.3-7+squeeze8 int(89) int(95) int(134) int(154) int(157) Maybe the warning was added in PHP 5.3.8 and further...