RE: [PHP] how to get var name and value from function?
| From: | Ford, Mike | Date: | Wed, 18 Apr 2007 09:57:45 +0000 |
| Subject: | RE: [PHP] how to get var name and value from function? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-253188@lists.php.net to get a copy of this message | ||
On 17 April 2007 01:18, Richard Lynch wrote:
> On Mon, April 16, 2007 12:10 pm, Ford, Mike wrote:
> > No, not "just another array" (although I agree about the function
> > being pretty useless!) -- $GLOBALS is a superglobal array that
> > contains a reference to every variable defined in the global scope,
> > so that accessing $GLOBALS['var'] from anywhere is the same as
> > accessing $var in the global scope. It's a way of referencing
> > global variables without having to use a "global $var" statement.
>
> So, as far as I can tell, you're avoiding using the documented feature
> "global $var" and cramming things into $GLOBALS which happens to work
> but is an undocumented feature?
>
> All the ills associated with "global $var" are still there, of course.
Of course -- this can be a matter of personal preference, but I have seen the use of $GLOBALS
advocated over the global keyword as part of the
knowing-where-your-data-came-from-at-the-point-of-use frame of mind.
> Or is it explicitly stated in the manual somewhere I'm not seeing that
> one can put things in $GLOBALS directly? [shrug]
http://uk2.php.net/manual/en/language.variables.predefined.php#language.variables.superglobals
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 812 4730 Fax: +44 113 812 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm