null Or Boolean As Array¶
<?php
var_dump(null [[]]); // NULL
var_dump(true [[]]); // NULL
var_dump(false [[]]); // NULL
var_dump( [][[]]); // fatal error
Null and booleans support the array syntax, but always return NULL as value. Since PHP 7.4, they also report a warning, as this is not good code.
Arrays also report errors when the key type is not valid, such as another array or an object.
Interestingly, Null and boolean accept illegal keys, with a simple warning.
See Also¶
Accessing index on literals [Try me]
PHP Error Messages¶
PHP Features¶
Last updated: 14 July 2026