Where are all my PHP variables hiding?
Posted October 28th, 2007 by Chris in
Sometimes it's difficult to remember what variables you have available to you at any given time, especially if your script is split into functions, or in my case you're working with Drupal, where there's a whole slew of variables available at your disposal, if only you know what they were called. Lucky for curious folks like us, there's a couple native PHP functions that will clear things up:
//Returns an array of all variables and their values. Sweet!
get_defined_vars();
//Prints out the contents of whatever variable you pass to it.
var_dump();
get_defined_vars();
//Prints out the contents of whatever variable you pass to it.
var_dump();
- Add new comment
- Read more



Be the first to comment on this post

