From the perspective of the PHP kernel to explain it to you, you can understand in depth, it is fully understood;
PHP variables in the kernel are stored by the C language structure Zval (you have not learned C, you can be understood as an object, the member variables are the properties of the class, for the time being understood first), the ZVAL structure is as follows:
struct _zval_struct {zvalue_value value;//storage variable zend_uint REFCOUNTGC;//= reference count defaults to: 1zend_uchar type;//variable-specific type Zend_uch AR IS_REFGC; Indicates whether it is a reference};
As an example, the PHP code is as follows:
$a = ten; $b = $a;
At this time $b no reference, just give a value of $ A $b, then zval the structure of the REFCOUNTGC becomes 2, and IS_REFGC or false, indicating unreferenced, because the kernel $ A has opened up a memory space, when $ A is assigned to $b, the value of $b only points to the $ A, this eliminates the re-opening of a piece of memory, but when the $b value is changed ($a value will not change), $b will open up a new memory space, this is how to copy, PHP variables in the kernel How to store, the following reference:
$a = ten; $b = & $a;
At this time, the kernel stores a $ A structure IS_REFGC labeled true, the Representative is a reference, then $ A and $b all point to the same memory address, when $b=20, the $a will become 20