function value(&$param){}
value($var['key']);
echo array_key_exists("key", $var)? "true" : "false"; //true
After running this code, $var['key'] ends up existing despite never being explicitly set. This means empty($var)
will no longer return true
, which kind of bothers me.
Is this behavior intended? I couldn't find documentation on that.
A simpler code that gives the same result :
$foo = &$bar['key'];
$echo array_key_exists('key', $bar)? "true" : "false";