I am using PHP 7.2. I come across the following note from the arrays chapter of PHP Manual
Array dereferencing a scalar value which is not a string silently yields NULL, i.e. without issuing an error message.
I understand how to dereference an array literal but I'm not able to understand how the "array dereferencing" works on a scalar value of type boolean/integer/float/string?
If you look at the code example from the PHP manual itself, you can notice the contradiction as it's not the value of integer type is not silently yielding NULL according to the manual.
<?php
function getArray() {
return array(1, 2, 3);
}
$secondElement = getArray()[1];
var_dump($secondElement); // int(2)
//According to the manual I expected it to be NULL as it's not of type string
How is dereferencing a scalar value of type boolean/integer/float different from dereferencing the value of type string?