如果你安装了xdebug,就可以用xdebug_debug_zval()显示“zval”的信息了。如下:
结果:
arr:
(refcount=1, is_ref=0),
array
'a' => (refcount=1, is_ref=0),string 'aaa' (length=3)
'b' => (refcount=1, is_ref=0),string 'bbb' (length=3)
arr:
(refcount=1, is_ref=0),
array
'a' => (refcount=2, is_ref=0),string 'aaa' (length=3)
'b' => (refcount=1, is_ref=0),string 'bbb' (length=3)
'aaa' => (refcount=2, is_ref=0),string 'aaa' (length=3)
可以看到看到原有的数组元素和新添加的数组元素关联到同一个refcount2的zval变量容器.这里我也只是起到抛砖引玉的作用。
具体关于php引用计数器可以参照手册:http://php.net/manual/zh/features.gc.refcounting-basics.php
欢迎转载! 原文地址: http://www.phpddt.com/php/gc-refcounting-basics.html ,转载请注明地址,谢谢!
