#43889 [Opn->Bgs]: When using isset to check a variable returning true for an array key when str
| From: | tony2001@php.net | Date: | Mon, 28 Jan 2008 23:23:29 +0000 |
| Subject: | #43889 [Opn->Bgs]: When using isset to check a variable returning true for an array key when str | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121630@lists.php.net to get a copy of this message | ||
ID: 43889
Updated by: tony2001@php.net
Reported By: rharrell at imagiclab dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: RH Enterprise 4
PHP Version: 5.2CVS-2008-01-18 (snap)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2008-01-18 18:57:43] rharrell at imagiclab dot com
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 this bug report at http://bugs.php.net/?id=43889&edit=1