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
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: 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: Sun Sep 29 01:01:26 2024 UTC