RE: [PHP] how to get var name and value from function?
| From: | Ford, Mike | Date: | Thu, 19 Apr 2007 08:34:40 +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-253250@lists.php.net to get a copy of this message | ||
On 19 April 2007 04:36, Richard Lynch wrote:
> On Wed, April 18, 2007 4:57 am, Ford, Mike wrote:
> > On 17 April 2007 01:18, Richard Lynch wrote:
> > > 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
>
> When I read that section of the manual, along with similar variables,
> such as: $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES, $_ENV, $_REQUEST
>
> I do not, in my mind, see anything indicating that it is a documented
> feature that cramming some value into $_GLOBALS['foo'] is
> specifically supported...
Well the definition of $GLOBALS says:
"Contains a reference to every variable which is currently available
within the global scope of the script."
I take that to mean reference as in the & operator, so that
$GLOBALS['foo'] is a reference to $foo, and when you assign to a
reference you also assign to....
But, notwithstanding that, how about Example 12.3 at http://php.net/global#language.variables.scope.global?
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
JG125, The Headingley Library,
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