#34419 [Opn->Bgs]: array_key_exists warns for large numeric keys

From: Date: Thu, 08 Sep 2005 05:32:23 +0000
Subject: #34419 [Opn->Bgs]: array_key_exists warns for large numeric keys
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-84675@lists.php.net to get a copy of this message
ID: 34419 Updated by: sniper@php.net Reported By: bsdson dot tw at yahoo dot com dot tw -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Linux PHP Version: 5.0.5 New Comment: "This is not a bug, the number you are using is NOT an integer because it's larger then 2^31-1 (the maximum integer value in PHP) and thus it will be converted to a float." This hasn't changed, will not change, and is not a bug. Previous Comments: ------------------------------------------------------------------------ [2005-09-08 06:05:13] bsdson dot tw at yahoo dot com dot tw Description: ------------ The same issue as Bug#21954, that 'array_key_exists' warns for large numeric keys! Bug#21954 is believed to be bogus, but I don't think so! From the manual of this function, it says that "key can be any value possible for an array index". Since the statement '$a[2163195907] = "hi";' is acceptable for PHP, the function should accept 2163195907 as the argument 'key', too. More, PHP is used as a type-less language, why should I bother from that?! Reproduce code: --------------- <?php $a = array(); $a[2163195907] = "hi"; echo array_key_exists(2163195907,$a); ?> Expected result: ---------------- true Actual result: -------------- Warning: array_key_exists(): The first argument should be either a string or an integer in bug.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34419&edit=1

« previous php.bugs (#84675) next »