Dumps a string representation of an internal zend value to output.
The variable being evaluated.
No value is returned.
<?php $var1 = 'Hello World'; $var2 = ''; $var2 =& $var1; debug_zval_dump(&$var1); ?>
The above example will output:
&string(11) "Hello World" refcount(3)
The refcount value returned by this function is non-obvious in certain circumstances. For example, a developer might expect the above example to indicate a refcount of 2. The third reference is created when actually calling debug_zval_dump().
This behavior is further compounded when a variable is not passed to debug_zval_dump() by reference. To illustrate, consider a slightly modified version of the above example:
<?php $var1 = 'Hello World'; $var2 = ''; $var2 =& $var1; debug_zval_dump($var1); // not passed by reference, this time ?>
string(11) "Hello World" refcount(1)
Why refcount(1)? Because a copy of $var1 is being made, when the function is called.
This function becomes even more confusing when a variable with a refcount of 1 is passed (by copy/value):
<?php $var1 = 'Hello World'; debug_zval_dump($var1); ?>
string(11) "Hello World" refcount(2)
Please login to continue.