Bug #70517 [Opn->Csd]: isset() on string produces invalid result

From: Date: Sun, 14 Jan 2018 14:57:08 +0000
Subject: Bug #70517 [Opn->Csd]: isset() on string produces invalid result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213537@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70517&edit=1

 ID:                 70517
 Updated by:         nikic@php.net
 Reported by:        jens dot rosenthal at compcom dot de
 Summary:            isset() on string produces invalid result
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Arrays related
 PHP Version:        5.5.29
-Assigned To:        
+Assigned To:        nikic
 Block user comment: N
 Private report:     N

 New Comment:

Closing per previous comment.


Previous Comments:
------------------------------------------------------------------------
[2015-09-19 01:27:19] 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.

------------------------------------------------------------------------
[2015-09-17 08:52:56] 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)



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70517&edit=1


Thread (3 messages)

« previous php.bugs (#213537) next »