[thelist] PHP variable list

Andrew Forsberg andrew at thepander.co.nz
Fri Apr 12 16:15:00 CDT 2002


On Sat, 2002-04-13 at 08:30, Bill Haenel wrote:
> I'd like to get a list of all of the variables used in a PHP script. I've
> used get_defined_vars() to output all of the varibales, environment or
> otherwise. It's fine for now, but I don't get undefined or empty variables.
> Probably what I need will be part of an editor or editor extension or
> something. Any suggestions?

Hi Bill

print_r($GLOBALS);
or
var_dump($GLOBALS);

will show empty variables, and, presumably, undefined ones too (haven't
checked). print_r will output them in a semi-human-readable format,
although var_dump looks nicer to me. There's also var_export() which
outputs php code that can be used to recreate the variable(s), but last
I checked that was available via. CVS only.

If you need to capture the output to store or manipulate in some way
then you'll need to use the output control functions (the ob_* group).

HTH
Andrew





More information about the thelist mailing list