Page

【PHP】使用xdebug查看PHP中的变量引用计数

1037Anson21-02-08


我使用的版本是php7.4,例子结果跟官网的不太一样,因为7.4引用计数有优化,官网的还是旧版本的
<?php
  
$a = 'a';
xdebug_debug_zval('a');

image.png

$a = "new string";
$b = $a;
xdebug_debug_zval( 'a' );

image.png

$a = "new string";
$b = &$a;
xdebug_debug_zval( 'a' );

image.png


https://www.php.net/manual/zh/features.gc.refcounting-basics.php




来自anson博客 

http://www.tp0.top

2021-02-08 22:36:54