The isset()
documentation clearly tells me that
isset()
only works with variables as passing anything else will result in a parse error. For checking if constants are set use thedefined()
function.
So,
echo (isset(null)) ? 'YES' : 'NO';
is giving the fatal error as excepted;
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
Question;
Why does isset(null['?'])
does not trow the same error;
echo (isset(null['?'])) ? 'YES' : 'NO';
NO
I'm expecting the same error, since
isset()
can't be used on non-variables.
I'm aware that
<?php
$x = NULL;
$x['?'] = 'hi';
echo gettype($x); // array
will set $x
to an array, however, (as expected) echo @gettype(null['1']);
stays null?