Referencing Variables

By default, assignment operators work by value—that is, they copy the value of an expression on to another. If the right-hand operand happens to be a variable, only its value is copied, so that any subsequent change to the left-hand operator is not reflected in the right-hand one.

Example:

<?php
$a = 5;
$b = $a;
$b = 10;
echo $a; // Print 5
?>

Naturally, you expect this to be the case, but there are circumstances in which you may want an assignment to take place by reference so that the left-hand operand becomes "connected" with the right-hand one: