From: christian at jul dot net
Operating system: Debian Linux (sid)
PHP version: 5.0.0RC1
PHP Bug Type: Arrays related
Bug description: Weird string offset E_WARNING behaviour
Description:
------------
The fact that PHP5 issues an E_WARNING on illegal string offset use, gives
a problem on checking values with isset and is_array. Furthermore it does
not behave consistent.
Might not be a real bug, since it is the 'Backward Incompatible Changes'
list, still the behavior seems to buggy to me.
Reproduce code:
---------------
test.php:
<?php
$a = 'this is not an array';
if(isset($a['foo']))
print '1';
if(isset($a['foo']['bar']))
print '2';
if(isset($a['foo']['bar']['doo']))
print '3';
?>
test2.php
<?php
$a = 'this is not an array';
if(is_array($a['foo']))
print '1';
if(is_array($a['foo']['bar']))
print '2';
if(is_array($a['foo']['bar']['doo']))
print '3';
?>
Expected result:
----------------
Nothing!
Maybe fatal error at line 4 in both scripts, would be ok, but not very
niced designed, and doesn't fit well into the type loose scheme of PHP.
IMHO.
Actual result:
--------------
Fatal error: Cannot use string offset as an array in
/var/www/sites/test.php on line 8
Fatal error: Cannot use string offset as an array in
/var/www/sites/test2.php on line 6
--
Edit bug report at http://bugs.php.net/?id=28107&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28107&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28107&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28107&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28107&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28107&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28107&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28107&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28107&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28107&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28107&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28107&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28107&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28107&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28107&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28107&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28107&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28107&r=float