#44587 [NEW]: Problems whene asking if a key of an array isset, and the variable is not array

From: Date: Tue, 01 Apr 2008 10:48:21 +0000
Subject: #44587 [NEW]: Problems whene asking if a key of an array isset, and the variable is not array
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-123817@lists.php.net to get a copy of this message
From: francesco at facconi dot eu Operating system: Linux 2.6.18-6-686 PHP version: 5.2.5 PHP Bug Type: Arrays related Bug description: Problems whene asking if a key of an array isset, and the variable is not array Description: ------------ I was evaluating a variable with isset. I don't know what kind of variable it is before evaluating. If I do a isset of a key of an array, and the variable is NOT an array, I receive a true response. I think this is not a good result. Reproduce code: --------------- function verify($var) { if (isset($var['key'])) { echo "OK"; } else { echo "NO"; } return; } verify ('asdfghjkl'); verify (array('key'=>'1', 'option'=>'2'); verify (array('action'=>'1', 'option'=>'2'); Expected result: ---------------- ## verify ('asdfghjkl'); NO ## verify (array('key'=>'1', 'option'=>'2'); OK ## verify (array('action'=>'1', 'option'=>'2'); NO Actual result: -------------- ## verify ('asdfghjkl'); OK ## verify (array('key'=>'1', 'option'=>'2'); OK ## verify (array('action'=>'1', 'option'=>'2'); NO -- Edit bug report at http://bugs.php.net/?id=44587&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44587&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44587&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44587&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44587&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44587&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44587&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44587&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44587&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44587&r=support Expected behavior: http://bugs.php.net/fix.php?id=44587&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44587&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44587&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44587&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44587&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44587&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44587&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44587&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44587&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44587&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44587&r=mysqlcfg

« previous php.bugs (#123817) next »