Although this should never appear in your application, my colleague showed me this funny code: $a = array(null=>1); print_r($a);
the result is
Array
(
[]=>1
)
If we do echo $a[null], the output is 1. However, if we echo $a[''], we get the same output as well.
If we try xdebug_debug_zval('a'), we can find out that internally, PHP use '', not null as the array index.
No comments:
Post a Comment