Yes After assigning $n - $a , $b will indicate $n .
This is because after the execution of $a=&$b both $a and $b refer to the same memory cell and become a reference variable ( is_ref=1 ) . And the reference counter ( refcount ) of this particular memory location is incremented by 1 . Now, any value that you assign to any of these links will point to the same value.
Doing $a=$n means that the value of $n will be stored in the location referenced by $a . And this is the same place as $b .
See an example here.
$a , $b , $n indicate different locations
php > $a = 4; php > $b = 2; php > xdebug_debug_zval('a'); // they are pointing different location a: (refcount=1, is_ref=0)=int(4) php > xdebug_debug_zval('b'); // they are pointing different location b: (refcount=1, is_ref=0)=int(2) php > $n = 42; php > xdebug_debug_zval('n'); n: (refcount=1, is_ref=0)=int(42)
$ a and $b both now become a link
php > $a = &$b; php > xdebug_debug_zval('b'); b: (refcount=2, is_ref=1)=int(2) php > xdebug_debug_zval('a');
Assigning a new value , NOT references to any of $a and $b
php > $a = $n; php > xdebug_debug_zval('a'); // a holds $n value '42' now a: (refcount=2, is_ref=1)=int(42) php > xdebug_debug_zval('b'); // same for b b: (refcount=2, is_ref=1)=int(42)
source share