2>/dev/null
Xdebug’s improved var_dump()
Summary:
Xdebug makes var_dump()
really usable, and includes a few other variable display functions for your development toolkit.
Part of my recent development environment upgrade was to install the Xdebug extension for PHP.
Before Snow Leopard I often had trouble with PEAR and PECL packages. Not sure what I was doing wrong, and I didn’t look into it all that closely. But after upgrading to Snow Leopard it was easy. I found PHP Developer’s Snow Leopard Upgrade Notes a helpful guide.
I’m still working out how to use it, but one very nice feature with no learning curve is how Xdebug overloads var_dump()
with its own version, and offers a few other variable display functions too. Where standard var_dump()
output looks like this:
array(2) {
["foo"]=>
string(3) "foo"
["bar"]=>
string(3) "bar"
}
and that only in the page source; in the browser itself it is even worse:
array(2) { ["foo"]=> string(3) "foo" ["bar"]=> string(3) "bar" }
Xdebug formats it to this:
array ‘foo’ => string ‘foo’ (length=3) ‘bar’ => string ‘bar’ (length=3)
This makes a huge difference when looking at a large, nested object. Also, you can set maximum string length, nesting, and number of children to display.
Posted 2010-03-05 (last modified 2010-03-06) under Xdebug, PHP