This is my setting:
display_startup_errors = on
display_errors = On
error_reporting = E_ALL | E_STRICT
//code1:
$a = "abcd";
xdebug_debug_zval('a');
The above line of code would create a zval container and associate it with the symbol a'. And would give the following o/p.
a: (refcount=1, is_ref=0)='abcd'
consider the folowing code now:
//code2:
$a;
echo":";xdebug_debug_zval('a'); echo "<br/>";
$a = "abcd";
xdebug_debug_zval('a'); echo "<br/>";
would generate the o/p;
:
a: (refcount=1, is_ref=0)='abcd'
from PHP manual's Reference Counting Basics : A zval container is created when a new variable is created with a constant value
Does this mean that,
1] No symbol is created when code similar to line 1 of code2 i.e.
$a;
is encountered. Since xdebug_debug_zval does not find the symbol / variable name 'a'. As per the statement from Reference Counting Basics no zval container is created.
2] A symbol is created only when code similar to line 3 of code2 i.e.$a = "abcd";
is encountered. i.e. a symbol gets created only when the variable is associated with a constant value & as per the statement from Reference Counting Basics a zval container is created and is associated with the symbol 'a'. And that line 1 of code2 i.e.$a;
is a useless piece of code.
For info on xdebug_debug_zval visit here.