There is a difference between PHP's address reference and the pointer in the C language. The pointer inside the C language stores the address where the contents of the variable are stored in memory.
Talk less, see examples first,
$a = "ABC";
$b =& $a;
echo $a; Output here: ABC
Echo $b; Output here: ABC
$b = "EFG";
echo $a; Here a $ A value becomes EFG so the output EFG
Echo $b; Output EFG Here
?>
In the above example, we all understand that we will not say more. So take a look at the following example?
$a = "ABC";
$b =& $a;
unset ($a);
Echo $b; Output here: ABC
?>
It turns out this way, when you unset a reference, you just break the binding between the variable name and the variable content. This does not mean that the contents of the variable are destroyed.
Here's a little episode.
PHP in the direction of the address (similar to the pointer) function is not implemented by the user itself, is implemented by the Zend Core, PHP refers to the use of "copy-on-write" principle, that is, unless a write operation, the same address to the variable or object is not copied.
In layman's words, if you have the following code
$a = "ABC";
$b = $a;
?>
In fact, $a and $b both point to the same memory address and not $ A and $b occupy different memory
2: If you add the following code based on the above code
$a = "EFG";
Since $ A and $b point to the memory of the data to be re-written once, at this time Zend core will automatically decide to automatically produce a $ A copy of the data for $b, re-request a piece of memory for storage