We can use xdebug_debug_zval () to view two pieces of information about the zval container, refcount and is_ref.
<?php
$a = 123456789;
xdebug_debug_zval ("a");
echo "PHP:" . PHP_VERSION;
?>
print out on the page:
a:
(refcount=0, is_ref=0)int 123456789
PHP:7.0.20
No, how to refcount = 0? remember that the document is 1 after assignment. Let"s try a piece of code
<?php
$a = (string)123456789;
xdebug_debug_zval ("a");
echo "PHP:" . PHP_VERSION;
?>
print out the result:
a:
(refcount=1, is_ref=0)string "123456789" (length=9)
PHP:7.0.20
Whether must be a string. Then I"ll just pass in the string
.$a = "123456789";
the result is still refcount=0. That"s weird.
I wonder why refcount equals 0.