var_dump
Prints the type and the value — for debugging.
Syntax
var_dump(mixed $value, mixed ...$values): voidParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | The value to show. |
| ...$values | mixed | Other values. |
Return value
voidThe function returns nothing.
Examples
Simple values:
<?php
var_dump(42);
var_dump('42');
var_dump(true);Output:
int(42)
string(2) "42"
bool(true)An array is shown with every key and type:
<?php
var_dump(['name' => 'Anna', 'age' => 25]);Output:
array(2) {
["name"]=>
string(4) "Anna"
["age"]=>
int(25)
}Notes
Unlike echo, the function shows the difference between 42 and '42', between false and an empty string. It must not appear on a live site.
See also
- gettype — Returns the name of a value's type.
- json_encode — Converts a value to a JSON string.
Related recipes
In the tutorial
- Errors and debugging — The kinds of PHP errors, error display settings, the log, turning warnings into exceptions and debugging techniques.