If I have an array in PHP that is currently null, shouldn’t accessing an undefined index present an E_NOTICE level error?
If I have the following snippet of code:
$myArray = null;
echo $myArray['foo']['bar'];
I would expect an error but it runs without issue. I’ve verified my log level to be set to E_ALL. Is there something I’m missing or is PHP happy returning null for undefined indexes as long as you aren’t trying to modify the data?
Yes, the undefined index only triggers for not null variables (don’t ask me why). This will trigger a notice though: