$var1 = 'Hello World'; $var2 = ''; $var2 =&$var1; debug_zval_dump(&$var1); $a = "aaa"; $b = & $a; //echo $b; //这里依然会输出aaa,用xdebug_debug_zval打印你就知道为什么了 xdebug_debug_zval("b");
打印结果
&string(11) "Hello World" refcount(3) b:
(refcount=2, is_ref=1),string
'aaa' (length=3)
如果不太明白,可以参考http://php.net/manual/zh/features.gc.refcounting-basics.php