PHP trivia here.
If we declare an array like this:
<?php $arr = [ 'foo' => 'bar', NULL => 'hello' ]; ?>
We can access it like this
print $arr[NULL];
This will print hello
. Why is this useful, relevant or necessary? Is it a PHP bug or a feature?
My only idea was that you could declare array with the NULL key being equal to an error message to explain to anyone who uses a NULL key that their key is null:
$arr[NULL] = 'Warning you have used a null key, did you mean to?';
Has anyone found this useful? Seems to be something to cause more harm than good.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…