Open In App

PHP debug_zval_dump() Function

The debug_zval_dump() is an inbuilt function in PHP where the string representation of an internal zval structure will be dumped to the output.

Syntax:



debug_zval_dump(mixed $value, mixed ...$values): void

Parameters: This function has two parameters:

Return Value: This function does not return anything.



Example 1: The following code demonstrates the debug_zval_dump() function.




<?php
  
// Define a variable
$var = "Hello World";
debug_zval_dump($var);
?>

Output:

string(11) "Hello World" refcount(2)

Example 2: The following code also demonstrates the debug_zval_dump() function by using 3 variables as references to the same string value.




<?php
  
// Define an array
$arr = array('a', 'b', 'c');
  
// Dump the array
debug_zval_dump($arr);
?>

Output:

array(3) refcount(3){
  [0]=>  string(1) "a" refcount(1)
  [1]=>  string(1) "b" refcount(1)
  [2]=>  string(1) "c" refcount(1)
}   

Reference: https://www.php.net/manual/en/function.debug-zval-dump.php

Article Tags :