Array reference always succeeds
php -r 'var_dump($a["foo"]);var_dump(&$a["foo"]);var_dump($a);'
PHP Notice: Undefined variable: a in Command line code on line 1
NULL
&NULL
array(1) {
["foo"]=>
NULL
}The WTF here is the lack of a second notice and the fact that the array changed. There is logic in this, of course, but it's weird to the extreme. You can even add a &$a['foo']['bar'] to this and despite &$a['foo'] not being an array it will still succeed.

Comments
Post new comment