PHP Accessing elements by reference

Input:
$a = array();
$b = $a['a'];
var_dump($a);

Output:
array(0) { }

Input:
$a = array();
$b = &$a['a'];
var_dump($a);

Output:
array(1) { ["a"]=> &NULL }

Accessing elements modifies state. I hate this.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>