The Linux Page

get_defined_vars() PHP function

Once in a while, I need to get the complete list of all the variables available in a PHP piece of code.

This is done with the get_defined_vars() PHP function. It's very simple, it returns an array of name / value pairs. You can then print that value using print_r() or var_dump().

That's it!