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
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: 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

Pull Requests

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-2026 The PHP Group
All rights reserved.
Last updated: Thu Jan 15 14:00:01 2026 UTC