<?php echo "<hr>Initialise<br>"; $a = 1; xdebug_debug_zval('a'); echo "<hr>Copy<br>"; $b = $a; xdebug_debug_zval('a'); xdebug_debug_zval('b'); echo "<hr>Ref<br>"; $c =& $a; xdebug_debug_zval('a'); xdebug_debug_zval('b'); xdebug_debug_zval('c'); echo "<hr>Change<br>"; $c = 2; xdebug_debug_zval('a'); xdebug_debug_zval('b'); xdebug_debug_zval('c');
<?php #Example #8 Adding the array itself as an element of it self $a = array( 'one' ); $a[] =& $a; xdebug_debug_zval( 'a' ); ?>
<?php #Example #1 Creating a new zval container $add = "new string 123"; xdebug_debug_zval('add'); ?>
* @param int $start * @param int $end * @param int $step * @return Generator */ function generator($start, $end, $step = 1) { for ($i = $start; $i <= $end; $i += $step) { (yield 'name' . $i); } } $coroutine = generator(1, 2); xdebug_debug_zval('coroutine'); $valid = $coroutine->valid(); xdebug_debug_zval('valid'); $coroutine->rewind(); $current = $coroutine->current(); xdebug_debug_zval('current'); $valid = $coroutine->valid(); xdebug_debug_zval('valid'); $coroutine->next(); $current2 = $coroutine->current(); xdebug_debug_zval('current2'); $valid = $coroutine->valid(); xdebug_debug_zval('valid'); $coroutine->next(); $current3 = $coroutine->current(); xdebug_debug_zval('current3'); $valid = $coroutine->valid(); xdebug_debug_zval('valid');
public function gc_action() { $a = array('cccc'); $b = $a; // $c = $a; $d = $a; $a[] =& $a; // unset($a); xdebug_debug_zval('a'); xdebug_debug_zval('b'); echo 8 % -2; print_r(C()); $this->display('index'); }
<?php $voo = array('a' => 42); //xdebug_debug_zval( array( 'voo' ) ); xdebug_debug_zval(array('voo', 'a'));
<?php function memoryUsage($usage, $base_memory_usage) { printf("Bytes diff: %d\n", $usage - $base_memory_usage); } $mem = memory_get_usage(); $mem = memory_get_usage(); memoryUsage(memory_get_usage(), $mem); $a = array(0, &$a); $b =& $a; unset($a); //unset($b); xdebug_debug_zval('a'); xdebug_debug_zval('b'); //gc_collect_cycles(); memoryUsage(memory_get_usage(), $mem);
<?php // baselineWithDebug.php echo "<hr><h3><code>numbers</code> created</h3>"; $numbers = array("tahi", "rua", "toru"); xdebug_debug_zval('numbers'); echo "<hr><h3><code>refToSecondElement</code> created</h3>"; $refToSecondElement =& $numbers[1]; xdebug_debug_zval('numbers'); xdebug_debug_zval('refToSecondElement'); echo "<hr><h3><code>copyOfNumbers</code> created</h3>"; $copyOfNumbers = $numbers; xdebug_debug_zval('numbers'); xdebug_debug_zval('refToSecondElement'); xdebug_debug_zval('copyOfNumbers'); echo "<hr><h3><code>copyOfNumbers[1]</code> changed</h3>"; $copyOfNumbers[1] = "two"; xdebug_debug_zval('numbers'); xdebug_debug_zval('refToSecondElement'); xdebug_debug_zval('copyOfNumbers'); echo "<hr><h3><code>copyOfNumbers[2]</code> changed</h3>"; $copyOfNumbers[2] = "three"; xdebug_debug_zval('numbers'); xdebug_debug_zval('refToSecondElement'); xdebug_debug_zval('copyOfNumbers');
/** * This function displays structured information about one or more variables that includes its type, value and refcount information. * Arrays are explored recursively with values. * This function is implemented differently from PHP's debug_zval_dump() function in order to work around the problems * that that function has because the variable itself is actually passed to the function. * Xdebug's version is better as it uses the variable name to lookup the variable in the internal symbol table and * accesses all the properties directly without having to deal with actually passing a variable to a function. * The result is that the information that this function returns is much more accurate than PHP's own function * for showing zval information. * @return void */ public function debugZval() { xdebug_debug_zval(); }