php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70517 isset() on string produces invalid result
Submitted: 2015-09-17 08:52 UTC Modified: 2018-01-14 14:57 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jens dot rosenthal at compcom dot de Assigned: nikic (profile)
Status: Closed Package: Arrays related
PHP Version: 5.5.29 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jens dot rosenthal at compcom dot de
New email:
PHP Version: OS:

 

 [2015-09-17 08:52 UTC] jens dot rosenthal at compcom dot de
Description:
------------
Taking the example (#2) from the documentation page of the isset-function (Example #2 isset() on String Offsets), and modifying the test to contain [0] references somewhere along the array path, you can see, that each of these references provide a 'true' result, despite this is clearly not correct (see attached script), since the first part of the array patch does not exist (so any subsequent path cannot exist either).

Test script:
---------------
<?php
$expected_array_got_string = 'einstring';
var_dump(isset($expected_array_got_string['und']));
var_dump(isset($expected_array_got_string['und'][0]));
var_dump(isset($expected_array_got_string['und'][0]['test']));
var_dump(isset($expected_array_got_string['und']['test'][1]));
var_dump(isset($expected_array_got_string['und']['test'][0]));
?>


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


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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-19 01:27 UTC] bwoebi@php.net
Just a quick note:
Works in PHP 7 as expected, PHP 5.5 won't be fixed though as sec only currently.
 [2018-01-14 14:57 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2018-01-14 14:57 UTC] nikic@php.net
Closing per previous comment.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 18:01:28 2024 UTC