php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34648 isset false positive on key to string
Submitted: 2005-09-26 19:25 UTC Modified: 2005-09-26 21:47 UTC
From: ira at cmiware dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 5.1.0RC1 OS: slackware
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ira at cmiware dot com
New email:
PHP Version: OS:

 

 [2005-09-26 19:25 UTC] ira at cmiware dot com
Description:
------------
isset() returns a false positive when testing if an array key is valid, as in:

Reproduce code:
---------------
$myarray['parts'][1] = 'test';
var_dump(isset($myarray['parts'][1]['test']));
var_dump(isset($myarray['parts'][1]['test4']));
var_dump(isset($myarray['parts'][1][0]));
var_dump(isset($myarray['parts'][1][1]));
var_dump(isset($myarray['parts'][1][2]));
var_dump(isset($myarray['parts'][1][3]));
var_dump(isset($myarray['parts'][1][4]));

Expected result:
----------------
bool(true) 
bool(false) 
bool(false) 
bool(false) 
bool(false) 
bool(false) 
bool(false)

Actual result:
--------------
bool(true) 
bool(true) 
bool(true) 
bool(true) 
bool(true) 
bool(true) 
bool(false) 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-26 19:27 UTC] ira at cmiware dot com
reproduce code should be:

$myarray['parts']['test'] = 1;
var_dump(isset($myarray['parts']['test']));
var_dump(isset($myarray['parts']['test4']));
var_dump(isset($myarray['parts'][0]));
var_dump(isset($myarray['parts'][1]));
var_dump(isset($myarray['parts'][2]));
var_dump(isset($myarray['parts'][3]));
var_dump(isset($myarray['parts'][4]));
 [2005-09-26 19:52 UTC] marcot@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Works for me with the latest CVS version.
 [2005-09-26 21:47 UTC] ira at cmiware dot com
The bug has been corrected in the latest CVS snapshot.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 28 23:01:27 2024 UTC