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

PHP PHP Basics (Retired) PHP Operators Logical Operators

1 Answer

Gareth Borcherds
Gareth Borcherds
9,372 Points

var_dump is a pretty powerful PHP function that I use all the time to help debug things. var_dump essentially will tell you what type of variable something is along with the value. So an example:

$variable = "test";
var_dump($variable);

//var_dump will output string(4) "test"

So this would tell you that the variable $variable is a string of length 4 with a value of test. You can use this to find out if something is an integer, boolean, and for arrays it'll actually do this for every element in the array. It's a great way to test if a function is actually returning data and what type of data it is. It's also easier than trying to figure out if you need to use print, print_r, or echo to output a variable value.