PHP var_dump() Function (original) (raw)
Last Updated : 30 Sep, 2024
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.
**Syntax
var_dump(mixed value,mixed...value, mixed ...value,mixed...values): void
**Parameters
- ****$value:** The variable or value to be dumped.
- ****$values:** Additional variables to dump (optional).
**Return Value
This 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 `
`
Output
int(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 `
`
Output
object(Test)#1 (2) { ["name"]=> string(3) "PHP" ["version"]=> int(8) }
**Example 3: The use of var_dump() function in nested array.
PHP `
["PHP", "JavaScript", "Python"], "frameworks" => ["Laravel", "React", "Django"] ]; var_dump($nestedArr); ?>`
Output
array(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" } }