Open In App

PHP debug_zval_dump() Function

Last Updated : 11 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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:

  • value: This parameter specifies the variable or value that is to be dumped.
  • values: This parameter specifies the variables or values to dump further.

Return Value: This function does not return anything.

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

PHP




<?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




<?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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads