Re: how to get var name and value from function?
| From: | Tijnema ! | Date: | Thu, 19 Apr 2007 14:21:48 +0000 |
| Subject: | Re: how to get var name and value from function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253262@lists.php.net to get a copy of this message | ||
On 4/19/07, Ford, Mike <M.Ford@leedsmet.ac.uk> wrote:
On 19 April 2007 04:36, Richard Lynch wrote: On Wed, April 18, 2007 4:57 am, Ford, Mike wrote:Hmm, that's quite ugly, what happens when defining a variable outside, and inside a function. and then get the reference to it? Will the first var be overwritten, and when the function ends, it will refer to the old var again? TijnemaOn 17 April 2007 01:18, Richard Lynch wrote: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! MikeOr is it explicitly stated in the manual somewhere I'm not seeing that one can put things in $GLOBALS directly? [shrug]
--------------------------------------------------------------------- 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.ukTel: +44 113 812 4730 Fax: +44 113 812 3211To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php