RE: [PHP] how to get var name and value from function?
| From: | Richard Lynch | Date: | Thu, 19 Apr 2007 03:36:07 +0000 |
| Subject: | RE: [PHP] how to get var name and value from function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253233@lists.php.net to get a copy of this message | ||
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...
In fact, considering the context, $_GLOBALS would be the ONLY one,
other than $_SESSION, which would be writable, really.
I mean, okay, you can cram things into $_POST, but that doesn't make
them magically have been posted from the browser, and you can cram
stuff into $_ENV, but, afaik, that isn't the same as calling SetEnv,
is it?
And you can't cram stuff into $_COOKIE to set cookies, right?
You sure can't cram a file into $_FILES easily... :-)
So, to me at least, I'm not reading that as a script-writable array to
alter global data, since there is no special notation there that one
can alter global variables just by hacking into that array.
Since there *IS* a globals syntax documented, I'm gonna stick with
that, personally, as a Documented Feature.
But this is just what *I*, a known heretic, consider Best Practice.
Y'all do whatever you want. :-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?