PHP var_dump() Function Last Updated : 30 Sep, 2024 Comments Improve Suggest changes Like Article Like Report The var_dump() function in PHP is used to display structured information about one or more variables. The structured information means type and value of the given variable. It outputs not just the value of the variable but also its data type and, in the case of arrays or objects, all of their structure.Syntaxvar_dump(mixed $value, mixed ...$values): voidParameters$value: The variable or value to be dumped.$values: Additional variables to dump (optional).Return ValueThis function does not return any value. It outputs the result directly to the browser or console. Example 1: Basic example of var_dump() function. PHP <?php $number = 123; $string = "Hello, World!"; $array = [1, 2, 3, "PHP", true]; var_dump($number); var_dump($string); var_dump($array); ?> Outputint(123) string(13) "Hello, World!" array(5) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> string(3) "PHP" [4]=> bool(true) } Example 2: The use of var_dump() function on objects. PHP <?php class Test { public $name = "PHP"; public $version = 8; } $obj = new Test(); var_dump($obj); ?> Outputobject(Test)#1 (2) { ["name"]=> string(3) "PHP" ["version"]=> int(8) } Example 3: The use of var_dump() function in nested array. PHP <?php $nestedArr = [ "languages" => ["PHP", "JavaScript", "Python"], "frameworks" => ["Laravel", "React", "Django"] ]; var_dump($nestedArr); ?> Outputarray(2) { ["languages"]=> array(3) { [0]=> string(3) "PHP" [1]=> string(10) "JavaScript" [2]=> string(6) "Python" } ["frameworks"]=> array(3) { [0]=> string(7) "Laravel" [1]=> string(5) "React" [2]=> string(6) "Django" } } Comment More infoAdvertise with us Next Article PHP var_dump() Function P PronabM Follow Improve Article Tags : Misc Web Technologies PHP PHP-basics PHP-function +1 More Practice Tags : Misc Similar Reads 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): voidParameters: This function has two parameters: value: This parameter specifies the variable or v 1 min read PHP | var_export() Function The var_export() is a built-in function in PHP which is used to return the structured value(information) of a variable that is passed to this function as a parameter. This function is similar to the var_dump() function.Syntax: var_export($var, $return) Parameters: This function accepts two parameter 1 min read PHP strval() Function The PHP strval() function converts a given variable to a string. It takes a scalar variable (like integers, floats, and booleans) and converts it to its string representation. For arrays, objects, and resources, it does not work and may produce unexpected results.Syntaxstrval( $variable ) Parameter: 3 min read PHP compact() Function The compact() function is an inbuilt function in PHP and it is used to create an array using variables. This function is the opposite of the extract() function. It creates an associative array whose keys are variable names and their corresponding values are array values. Syntax: array compact("varia 2 min read PHP | get_defined_vars() Function The get_defined_vars() function is an inbuilt function in PHP which is used to returns an array of all defined variables. This function returns a multidimensional array which contains all the list of variables, environment etc. Syntax: array get_defined_vars( void ) Parameters: This function does no 1 min read Like