If you install Xdebug, you can use Xdebug_debug_zval () to display the "Zval" message. As follows:
Copy the Code code as follows:
$str = "Jb51.net";
Xdebug_debug_zval (' str ');
Results:
Str:
(Refcount=1, is_ref=0),
String ' jb51.net ' (length=10)
The variable container is destroyed only when "RefCount" becomes 0 o'clock. When you unset () a variable, the refcount in the desired "zval" will be reduced by 1, then the unset reference problem encountered in the previous days:
Copy the Code code as follows:
$a = "AAA";
$b = & $a;
unset ($a);
Echo $b; This will still output AAA, print with Xdebug_debug_zval and you'll know why.
Xdebug_debug_zval ("B");
Results:
B:
(Refcount=1, is_ref=0), String ' aaa ' (length=3)
Continue to refer to the counter problem, which is different for array and object conforming types:
Copy the Code code as follows:
$arr = Array (' a ' = = ' aaa ', ' b ' = ' BBB ');
Xdebug_debug_zval (' arr ');
$arr [' aaa '] = $arr [' a '];
Xdebug_debug_zval (' arr ');
?>
Results:
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)
You can see that the original array element and the newly added array element are associated to the Zval variable container of the same "RefCount" 2. I'm just playing a role here.
Specific reference counters for PHP can be referenced in the manual: http://php.net/manual/zh/features.gc.refcounting-basics.php
http://www.bkjia.com/PHPjc/327870.html www.bkjia.com true http://www.bkjia.com/PHPjc/327870.html techarticle If you install Xdebug, you can use Xdebug_debug_zval () to display the "Zval" message. As follows: Copy code code as follows: PHP $str = "Jb51.net"; Xdebug_debug_zval (' str '); Result: .....