I read quite a few articles about how the variables are arranged inside the Zend machine and found out one interesting thing that I can not explain:
$int = 100; xdebug_debug_zval('int');/// int:(refcount=1, is_ref=0),int 100 $int = &$int; xdebug_debug_zval('int');/// int:(refcount=1, is_ref=1),int 100 How is it that we create the link to itself? How is that even possible? I did not see anything like this, if you will put down cons, then please argue your choice.
Some information from what I know:
As a rule, is_ref=1 only if zval container is referenced by 2 or more variables by a hard link.
refcount is the number of variables referring to the same zval container, but the difference is that is_ref=0 works differently with is_ref=0 and is_ref=1 .
If is_ref=0 , and refcount > 1 then when creating hard links, a new zval container is created, if we make an assignment by value, then the new zval not created, but the old one is used.
If is_ref=1 , and refcount > 1 then when creating hard links, a new zval not created, but the old one is used, but if we do not create a hard link, we assign a new zval container by value.
PS I wrote this in order to show that I understand perfectly what I ask, and also show why the behavior of the code I wrote above is incomprehensible to me.
PS Fabulous
Note that if "refcount" is 1, then "is_ref" will always be equal to FALSE. http://php.net/manual/ru/features.gc.refcounting-basics.php