>Xdebug replaces PHP's var_dump() function for displaying variables. Xdebug's version includes different colors for different types and places limits on the amount of array elements/object properties, maximum depth and string lengths. There are a few other functions dealing with variable display as well.
##Effect of settings on var_dump()
There is a number of settings that control the output of Xdebug's modified var_dump() function: xdebug.var_display_max_children, xdebug.var_display_max_data and xdebug.var_display_max_depth. The effect of these three settings is best shown with an example. The script below is run four time, each time with different settings. You can use the tabs to see the difference.
##The script
```
<?php
class test {
public $pub = false;
private $priv = true;
protected $prot = 42;
}
$t = new test;
$t->pub = $t;
$data = array(
'one' => 'a somewhat long string!',
'two' => array(
'two.one' => array(
'two.one.zero' => 210,
'two.one.one' => array(
'two.one.one.zero' => 3.141592564,
'two.one.one.one' => 2.7,
),
),
),
'three' => $t,
'four' => range(0, 5),
);
var_dump( $data );
?>
```
##The results
|[default](#default)|[children=2](#children)|[data=16](#data)|[depth=2](#depth)|[children=3, data=8, depth=1](#all) |
|||||
<span id="default"></span>
```
array
'one' => string 'a somewhat long string!' (length=23)
'two' =>
array
'two.one' =>
array
'two.one.zero' => int 210
'two.one.one' =>
array
...
'three' =>
object(test)[1]
public 'pub' =>
&object(test)[1]
private 'priv' => boolean true
protected 'prot' => int 42
'four' =>
array
0 => int 0
1 => int 1
2 => int 2
3 => int 3
4 => int 4
5 => int 5
```
<span id="children" ></span>
```
array
'one' => string 'a somewhat long string!' (length=23)
'two' =>
array
'two.one' =>
array
'two.one.zero' => int 210
'two.one.one' =>
array
...
more elements...
```
<span id="data"></span>
```
array
'one' => string 'a somewhat long '... (length=23)
'two' =>
array
'two.one' =>
array
'two.one.zero' => int 210
'two.one.one' =>
array
...
'three' =>
object(test)[1]
public 'pub' =>
&object(test)[1]
private 'priv' => boolean true
protected 'prot' => int 42
'four' =>
array
0 => int 0
1 => int 1
2 => int 2
3 => int 3
4 => int 4
5 => int 5
```
<span id="depth" ></span>
```
array
'one' => string 'a somewhat long string!' (length=23)
'two' =>
array
'two.one' =>
array
...
'three' =>
object(test)[1]
public 'pub' =>
&object(test)[1]
private 'priv' => boolean true
protected 'prot' => int 42
'four' =>
array
0 => int 0
1 => int 1
2 => int 2
3 => int 3
4 => int 4
5 => int 5
```
<span id="all"></span>
```
array
'one' => string 'a somewh'... (length=23)
'two' =>
array
...
'three' =>
object(test)[1]
...
more elements...
```
##Related Settings
**xdebug.cli_color**
Type: integer, Default value: 0, Introduced in Xdebug > 2.2
If this setting is 1, Xdebug will color var_dumps and stack traces output when in CLI mode and when the output is a tty. On Windows, the ANSICON tool needs to be installed.
If the setting is 2, then Xdebug will always color var_dumps and stack trace, no matter whether it's connected to a tty or whether ANSICON is installed. In this case, you might end up seeing escape codes.
See this article for some more information.
**xdebug.overload_var_dump**
_Type: boolean, Default value: 1, Introduced in Xdebug > 2.1_
By default Xdebug overloads var_dump() with its own improved version for displaying variables when the html_errors php.ini setting is set to 1. In case you do not want that, you can set this setting to 0, but check first if it's not smarter to turn off html_errors.
You can also use 2 as value for this setting. Besides formatting the var_dump() output nicely, it will also add filename and line number to the output. The xdebug.file_link_format setting is also respected. (New in Xdebug 2.3)
**xdebug.var_display_max_children**
_Type: integer, Default value: 128_
Controls the amount of array children and object's properties are shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces.
To disable any limitation, use -1 as value.
This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature.
**xdebug.var_display_max_data**
_Type: integer, Default value: 512_
Controls the maximum string length that is shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces.
To disable any limitation, use -1 as value.
This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature.
**xdebug.var_display_max_depth**
_Type: integer, Default value: 3_
Controls how many nested levels of array elements and object properties are when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Traces.
The maximum value you can select is 1023. You can also use -1 as value to select this maximum number.
This setting does not have any influence on the number of children that is send to the client through the Remote Debugging feature.
##Related Functions
**void var_dump( [mixed var [, ...]] )**
_Displays detailed information about a variable_
This function is overloaded by Xdebug, see the description for xdebug_var_dump().
**void xdebug_debug_zval( [string varname [, ...]] )**
_Displays information about a variable_
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. This function is implemented differently from PHP's debug_zval_dump() function in order to work around the problems that that function has because the variable itself is actually passed to the function. Xdebug's version is better as it uses the variable name to lookup the variable in the internal symbol table and accesses all the properties directly without having to deal with actually passing a variable to a function. The result is that the information that this function returns is much more accurate than PHP's own function for showing zval information.
Support for anything but simple variable names (such as "a[2]" below) is supported since Xdebug 2.3.
**Example:**
```
<?php
$a = array(1, 2, 3);
$b =& $a;
$c =& $a[2];
xdebug_debug_zval('a');
xdebug_debug_zval("a[2]");
?>
```
**Returns:**
```
a: (refcount=2, is_ref=1)=array (
0 => (refcount=1, is_ref=0)=1,
1 => (refcount=1, is_ref=0)=2,
2 => (refcount=2, is_ref=1)=3)
a[2]: (refcount=2, is_ref=1)=3
```
**void xdebug_debug_zval_stdout( [string varname [, ...]] )**
_Returns information about variables to stdout._
This function displays structured information about one or more variables that includes its type, value and refcount information. Arrays are explored recursively with values. The difference with xdebug_debug_zval() is that the information is not displayed through a web server API layer, but directly shown on stdout (so that when you run it with Apache in single process mode it ends up on the console).
**Example:**
```
<?php
$a = array(1, 2, 3);
$b =& $a;
$c =& $a[2];
xdebug_debug_zval_stdout('a');
```
**Returns:**
```
a: (refcount=2, is_ref=1)=array (
0 => (refcount=1, is_ref=0)=1,
1 => (refcount=1, is_ref=0)=2,
2 => (refcount=2, is_ref=1)=3)
```
**void xdebug_dump_superglobals()**
_Displays information about super globals_
This function dumps the values of the elements of the super globals as specified with the xdebug.dump.* php.ini settings. For the example below the settings in php.ini are:
**Example:**
```
xdebug.dump.GET=*
xdebug.dump.SERVER=REMOTE_ADDR
Query string:
?var=fourty%20two&array[a]=a&array[9]=b
```
**Returns:**
| Dump $_SERVER |
| ------------- |:-------------:|
| `$_SERVER['REMOTE_ADDR'] =` | `string '127.0.0.1' (length=9)` |
| Dump $_GET |
| ------------- |:-------------:|
| `$_GET['var'] = ` | `string 'fourty two' (length=10)`|
| `$_GET['array'] =` | ` array` <br/>`'a' => string 'a' (length=1)`<br/> `9 => string 'b' (length=1) ` |
**void xdebug_var_dump( [mixed var [, ...]] )**
_Displays detailed information about a variable_
This function displays structured information about one or more expressions that includes its type and value. Arrays are explored recursively with values. See the introduction of Variable Display Features on which php.ini settings affect this function.
**Example:**
```
<?php
ini_set('xdebug.var_display_max_children', 3 );
$c = new stdClass;
$c->foo = 'bar';
$c->file = fopen( '/etc/passwd', 'r' );
var_dump(
array(
array(TRUE, 2, 3.14, 'foo'),
'object' => $c
)
);
?>
```
**Returns:**
```
array
0 =>
array
0 => boolean true
1 => int 2
2 => float 3.14
more elements...
'object' =>
object(stdClass)[1]
public 'foo' => string 'bar' (length=3)
public 'file' => resource(3, stream)
```