php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43889 When using isset to check a variable returning true for an array key when str
Submitted: 2008-01-18 18:57 UTC Modified: 2008-01-28 23:23 UTC
From: rharrell at imagiclab dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2CVS-2008-01-18 (snap) OS: RH Enterprise 4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rharrell at imagiclab dot com
New email:
PHP Version: OS:

 

 [2008-01-18 18:57 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-28 23:23 UTC] tony2001@php.net
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


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 03:01:31 2025 UTC