Bug #70517 [NEW]: isset() on string produces invalid result
| From: | jens dot rosenthal at compcom dot de | Date: | Thu, 17 Sep 2015 08:52:59 +0000 |
| Subject: | Bug #70517 [NEW]: isset() on string produces invalid result | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-196052@lists.php.net to get a copy of this message | ||
From: jens dot rosenthal at compcom dot de
Operating system:
PHP version: 5.5.29
Package: Arrays related
Bug Type: Bug
Bug description:isset() on string produces invalid result
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 bug report at https://bugs.php.net/bug.php?id=70517&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70517&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70517&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70517&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70517&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70517&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70517&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70517&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70517&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70517&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70517&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70517&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70517&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70517&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70517&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70517&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70517&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70517&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70517&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70517&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70517&r=mysqlcfg