I read a lot of articles about how to construct the variables inside the machine Zend and found 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
As it turns out that we are creating the link itself to itself? How is it possible?
Clear information from what I know:
As a rule is_ref = 1
only when the container refers zval two or more variables of hard link.
refcount
- is the number of variables refer to the same zval container, but the difference is that the refcount for different works with is_ref = 0
and is_ref = 1
.
If is_ref = 0
, and refcount > 1
when creating hard links, we get a new zval container, if we do the assignment by a value - new zval container will not be created.
If is_ref = 1
, and refcount > 1
when creating hard links new zval is not created, used old. if we do not create a hard link, but do assigning by a value - it means what we created new zval container.
P.S I wrote this in order to show that understand that I ask and show why I do not understand the behavior of the code that I have written above
$int = &$int
- what the ??? is this? – Unthreadrefcount
, she still yet is 1 – Unthread$a = 10; $b = &a;
And here$a = 10; $a = &$a;
Thanks – Unthread