2.3.2. Variable References
In PHP, references are how you create variable aliases. To make
$black an alias for the variable
$white, use:
$black =& $white;
The old value of $black is lost. Instead,
$black is now another name for the value that is
stored in $white:
$big_long_variable_name = "PHP";
$short =& $big_long_variable_name;
$big_long_variable_name .= " rocks!";
print "\$short is $short\n";
print "Long is $big_long_variable_name\n";
$short is PHP rocks!
Long is PHP rocks!
$short = "Programming $short";
print "\$short is $short\n";
print "Long is $big_long_variable_name\n";
$short is Programming PHP rocks!
Long is Programming PHP rocks!
After the assignment, the two variables are alternate names for the
same value. Unsetting a variable that is aliased does not affect
other names for that variable's value, though:
$white = "snow";
$black =& $white;
unset($white);
print $black;
snow