Re: Variables Help
| From: | John W. Holmes | Date: | Thu, 13 May 2004 18:54:33 +0000 |
| Subject: | Re: Variables Help | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186141@lists.php.net to get a copy of this message | ||
From: "Monty" <monty3@hotmail.com>
> >> Is there a variable that I can call that will return an array with any
> >> variables I have set? I'd want to call it and then parse and display
> > current
> >> values of, in this case, a and b. Hope that makes sense.
> >
> > Like something that "Returns an array of all defined variables"??
> >
> > http://us2.php.net/get_defined_vars
> >
> > ---John Holmes...
>
> Is there any way to get JUST the user-defined variables in PHP? Problem
with
> get_defined_vars() is that it contains everything, including server and
> environment vars, and there's no easy way to keep just the user-defined
vars
> part of the array created by get_defined_vars.
<?php
$starting_vars = get_defined_vars();
//bunch of PHP code...
$current_vars = get_defined_vars();
$user_defined_vars = array_diff($current_vars,$starting_vars);
...
---John Holmes...