Edit report at http://bugs.php.net/bug.php?id=52025&edit=1
ID: 52025 User updated by: djmix-2006 at hotmail dot com Reported by: djmix-2006 at hotmail dot com Summary: Array keys type cast error when use maximum integer value -Status: Feedback +Status: Open Type: Bug Package: Scripting Engine problem Operating System: Windows -PHP Version: 5.2.13 +PHP Version: 5.2.9 New Comment: No problem on 5.2.13. Yes on PHP 5.2.9 and PHP 5.2.5 Previous Comments: ------------------------------------------------------------------------ [2010-06-09 03:53:12] fel...@php.net Please try using this snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ I cannot reproduce it on 5.2.14-dev... ------------------------------------------------------------------------ [2010-06-09 02:32:01] djmix-2006 at hotmail dot com Description: ------------ Tested on PHP 5.2.9 When trying to check if a key exists into an array, and the key is the standard representation of an integer, php must interpreted as such like the documentation says: (i.e. "8" will be interpreted as 8, while "08" will be interpreted as "08") This don't happens when the value of the key is the same than the maximum value of an integer (PHP_INT_MAX). Assuming that PHP_INT_MAX is 2147483647, the two lines below will not return true as expected. isset($array[2147483647]); //true isset($array['2147483647']); //false This doesn't happens when key is smaller than the maximum value of an integer. isset($array[2147483646]); //true isset($array['2147483646']); //true Test script: --------------- <?php $maxInteger = (int)PHP_INT_MAX; $keyInt = $maxInteger; $keyStr = strval($keyInt); echo "Maximum value is $maxInteger \n"; $arr = array($keyInt => 1); echo 'Key Integer exists: ' . (int)isset($arr[$keyInt]) . "\n"; //Yes echo 'Key String exists: ' . (int)isset($arr[$keyStr]) . "\n"; //No $keyInt = $maxInteger - 1; $keyStr = strval($keyInt); echo 'Key Integer exists: ' . (int)isset($arr[$keyInt]) . "\n"; //Yes echo 'Key String exists: ' . (int)isset($arr[$keyStr]) . "\n"; //Yes ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52025&edit=1