What References Do in PHP (&)?

Makes Two variables refer to the same content. Hence, If you change one Other will too.

$a='some value';
$b='other value';

$a =& $b; // assigning reference

echo $a.'<br>'; //now $a has 'other value'

//if we change $a
$a = 'new value';

echo $b; //now $b is new 'value'

other value
new value

Leave a Reply

Your email address will not be published. Required fields are marked *