From:
Operating system: Linux
PHP version: 5.3.5
Package: Variables related
Bug Type: Bug
Bug description:Insufficient+Inconsistent error reporting
Description:
------------
If you try to access an undefined index on an array, you will get an error.
But if you try the same on bool(false) PHP will silently accept it and
ignores the error.
Please note that this is especially dangerous on database results, where
you get false instead of an array when there is no result.
If you try the same on a valid array with an invalid index you will get a
E_NOTICE.
So trying to use the array operator on a non-array should at least raise an
E_STRICT error, indicating that there is a problem, instead of silently
continuing to use the wrong result for further calculations.
Test script:
---------------
$array1 = false;
$array2 = array('a'=>3);
echo 5+3*$array1['a']; // output: 5
var_dump($array1['b']); // output: NULL
var_dump($array2['b']); // output: <b>Notice</b>: Undefined index: b
--
Edit bug report at http://bugs.php.net/bug.php?id=54155&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54155&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54155&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54155&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54155&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54155&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54155&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54155&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54155&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54155&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54155&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54155&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54155&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54155&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54155&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54155&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54155&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54155&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54155&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54155&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54155&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54155&r=mysqlcfg