RE: how to get var name and value from function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Or is it explicitly stated in the manual somewhere I'm not seeing that
one can put things in $GLOBALS directly? [shrug]

I'd just use "global $$var" personally, if I was gonna do this at all...

As a "middle ground" one could have a SINGLE global variable, say,
$DATA, and use the var names as keys in that...

Still not something I'd really recommend doing, but at least it's less
problematic than having a zillion global vars with generic names like
$name running all through your application.

-- 
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux