PHP.nl

debug_zval_dump

debug_zval_dump

Dumps a string representation of an internal zval structure to output

void **debug_zval_dump** mixed $value mixed $values

Dumps a string representation of an internal zval (Zend value) structure to output. This is mostly useful for understanding or debugging implementation details of the Zend Engine or PHP extensions.

valueThe variable or value to dump.

valuesFurther variables or values to dump.

return.void

Voorbeeld: example

<?php
$var1 = 'Hello';
$var1 .= ' World';
$var2 = $var1;

debug_zval_dump($var1);
?>
string(11) "Hello World" refcount(3)

Opmerking: > ### Understanding the refcount

The  value shown by this function may be
surprising without a detailed understanding of the engine's implementation.

refcount

The Zend Engine uses reference counting for two different purposes:

References Explaineddebug_zval_dump

Because  takes its input as normal
parameters, passed by value, the copy on write technique will be used
to pass them: rather than copying the data, the refcount will be increased
by one for the lifetime of the function call. If the function modified the
parameter after receiving it, then a copy would be made; since it does not,
it will show a refcount one higher than in the calling scope.

debug_zval_dump

The parameter passing also prevents 
showing variables which have been assigned by reference. To illustrate,
consider a slightly modified version of the above example:

`debug_zval_dump````php


```php
string(11) "Hello World" refcount(2)
Although , , and
 are linked as references, only the
 is passed to .
That value is used once by the set of references, and once inside the
, so shows a refcount of 2.

$var1``$var2``$var3valuedebug_zval_dump``debug_zval_dump

Further complications arise because of optimisations made in the engine for different data types. Some types such as integers do not use "copy on write", so do not show a refcount at all. In other cases, the refcount shows extra copies used internally, such as when a literal string or array is stored as part of a code instruction.

var_dump``debug_backtraceReferences ExplainedReferences Explained (by Derick Rethans)