#43889 [NEW]: When using isset to check a variable returning true for an array key when str
| From: | rharrell at imagiclab dot com | Date: | Fri, 18 Jan 2008 18:57:43 +0000 |
| Subject: | #43889 [NEW]: When using isset to check a variable returning true for an array key when str | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-121395@lists.php.net to get a copy of this message | ||
From: rharrell at imagiclab dot com
Operating system: RH Enterprise 4
PHP version: 5.2CVS-2008-01-18 (snap)
PHP Bug Type: Unknown/Other Function
Bug description: When using isset to check a variable returning true for an array key when str
Description:
------------
If a variable is set to a string and isset() is used to check an array key
for that variable it returns true.
Reproduce code:
---------------
$var="foo";
if(isset($var['ed']))
{
//why are we in this section if $var is a string?
if(is_array($var))
{
// This doesn't happen
echo "It's an array";
}
else
{
// And yet this returns "f"
echo $var['ed'];
}
}
Expected result:
----------------
I would expect isset to return false;
Actual result:
--------------
isset returns true, because a check for any associative array index for
the var will return the first character.
--
Edit bug report at http://bugs.php.net/?id=43889&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43889&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43889&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43889&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43889&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43889&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=43889&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43889&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43889&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43889&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43889&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43889&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=43889&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=43889&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43889&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43889&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43889&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43889&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43889&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43889&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43889&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43889&r=mysqlcfg