Each php variable exists in a variable container named & quot; zval & quot. A zval variable container not only contains the type and value of the variable, but also contains two bytes of additional information. Each php variable is stored in a variable container named "zval. A zval variable container not only contains the type and value of the variable, but also contains two bytes of additional information. The first is "is_ref", which is a bool value to identify whether the variable belongs to the reference set ). With this byte, the php engine can distinguish between common variables and reference variables. because php allows users to use & to use custom references, the zval variable container also has an internal reference counting mechanism, to optimize memory usage. The second extra byte is "refcount", used to indicate the number of variables (also known as symbol) pointing to the zval variable container. All symbols exist in a symbol table. each symbol has a scope, and the primary scripts (for example, scripts requested by a browser) and each function or method have a scope.
When a variable is assigned a constant value, a zval variable container is generated, as shown in the following example:
Example #1 create a new zval container
The above is the garbage collection mechanism of PHP features 1-reference the basic knowledge of counting content. For more information, please follow the PHP Chinese network (www.php1.cn )!