How to get the variables available within a PHP script or page

When you’re in there working your butt off, sometimes you have issues with what variables are available to you. For example, you might be working with some open source code like Drupal or WordPress, and you might not know based on the documentation what variables you have available to you. Here’s a way of finding that out with some simple PHP:

This will return a multidimensional array containing a list of all defined variables.

Why would I do this?

When coding a Drupal theme or a WordPress theme, you don’t always know what the system gives you, even if you read the docs. Also, when you’re debugging, you may have a variable hidden somewhere in the code that is messing things up. This is good for debugging your code.

Leave a comment

Find the Best SEO in Fort Lauderdale, Florida (Plantation SEO) | Drupal & Worpress Develpment