Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Jeo Paloma
Jeo Paloma
2,472 Points

Could someone explain var_dump to me in a simple way please thank you

I'm a newbie and var_dump is a bit confusing to me

1 Answer

Simon Coates
Simon Coates
28,694 Points

it displays value and data type for what is contained in a variable. see http://php.net/manual/en/function.var-dump.php for the official explanation and examples. The examples are pretty helpful and cover a few different variable types.

I don't think it's something you'd use in a real live website. It's just something you use when you want to see what value you have (in a debugging context). To output a value normally, you'd use echo or print. However, sometimes you just want a quick look at a variable when you're putting a page together, or want more precise information. (some different values may produce the same output using echo, making it unclear as to the precise contents of a variable).