Edit report at https://bugs.php.net/bug.php?id=54155&edit=1
ID: 54155 User updated by: a1283465 at jnxjn dot com Reported by: a1283465 at jnxjn dot com Summary: Insufficient+Inconsistent error reporting Status: Open Type: Bug Package: Variables related Operating System: Linux PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: "I'd argue that one should check that a variable is of an expected type" I totally agree with that. But isn't error reporting (especially NOTICE etc) exactly for finding such bad code pieces? Previous Comments: ------------------------------------------------------------------------ [2012-02-24 20:09:23] robertbasic dot com at gmail dot com I'd argue that one should check that a variable is of an expected type, or maybe cast the type to the expected one, before using it. I vote for "Not a bug". ------------------------------------------------------------------------ [2011-03-03 23:23:32] a1283465 at jnxjn dot com 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 this bug report at https://bugs.php.net/bug.php?id=54155&edit=1