I'm not sure this is a bug, so can anyone tell why does not php show a notice if you try to access a key which is not defined of an array that is NULL? Documentation says
Converting NULL to an array results in an empty array.
So accessing a key that is not defined must generate notice.
<?php
$a = NULL;
echo $a['1'];
$a = array();
echo $a['1'];
?>
Prints out ony
Notice: Undefined offset: 1 in /var/www/shared/1.php on line 14
Thank you for your help.
Edit: I take the liberty of adding another example script to the question
<?php
$a = NULL;
var_dump('line '.__LINE__, $a['1']);
$a = array();
var_dump('line '.__LINE__, $a['1']);
which prints
string(6) "line 3"
NULL
Notice: Undefined offset: 1 in [...]/test.php on line 6
string(6) "line 6"
NULL
var_dump($a['1'])=>NULL.Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42].nullis not converted to anything -- simply indexing intonullalways returnsnullno matter the index you use". Why? Because PHP. But the source is too convoluted for me to back this up with facts.PHP Notice: Uninitialized string offset: 1 in ...error in that case. Which isn't triggered either.