From:             rattray at purdue dot edu
Operating system: windows and unix
PHP version:      4.3.4
PHP Bug Type:     *Programming Data Structures
Bug description:  isset() gives false positives for array subkeys

Description:
------------
using isset() to detect the existence of array subkeys give a false
positive.  Also, trying to print the content of said non-existing keys
gives the first character of the parent key!

Reproduce code:
---------------
$aArray = array();

$aArray["key"] = "value";

print("<PRE>".print_r($aArray, true)."</PRE>");

if (isset($aArray))

        print("Array exists<BR>");

else print("Array does not exist.<BR>");

if (isset($aArray["key"]))

        print("Array[key] exists, value = '".$aArray["key"]."'<BR>");

else print("Array[key] does not exist.<BR>");

if (isset($aArray["key"]["subkey"]))

        print("Array[key][subkey] exists, value =
'".$aArray["key"]["subkey"]."'<BR>");

else print("Array[key][subkey] does not exist.<BR>");



Expected result:
----------------
Array

(

    [key] => value

)



Array exists

Array[key] exists, value = 'value'

Array[key][subkey] does not exist

Actual result:
--------------
Array

(

    [key] => value

)



Array exists

Array[key] exists, value = 'value'

Array[key][subkey] exists, value = 'v'

-- 
Edit bug report at http://bugs.php.net/?id=27677&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27677&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27677&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27677&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27677&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27677&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27677&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27677&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27677&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27677&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27677&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27677&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27677&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27677&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27677&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27677&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27677&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27677&r=float

Reply via email to