Re: Opinion about the using $GLOBALS directly

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

 



On Wed, December 19, 2007 10:14 am, Stut wrote:
> Richard Lynch wrote:
>> On Wed, December 19, 2007 4:13 am, Sancar Saran wrote:
>>> I want know  to you opinions about using $GLOBALS directly.
>>>
>>> like
>>>
>>> $GLOBALS['myString'] = 'test';
>>> $GLOBALS['myArray']['this'] = 'this';
>>> $GLOBALS['myArray']['that'] = 'that';
>>> $GLOBALS['myClassObj] = new SomeClass;
>>
>> Don't.
>>
>> You are using global variables, and you might as well admit it and
>> use
>> the 'global' keyword to designate them as such.
>>
>> Poking stuff into $GLOBALS instead just makes it look like you're
>> trying to pretend you're not using global variables when you are, to
>> me.
>>
>> I did form this opinion before altering $GLOBALS was a documented
>> feature.
>
> I would have to disagree. Using the global keyword makes it less
> obvious
> that the variable your dealing with is in the global scope. Using
> $GLOBALS instead makes it clear to anyone looking at the code that
> you're dealing with a global variable.

Since the global keyword MEANS that the variable is in the global
scope, I'm having a hard time seeing how it's less clear that the
variable is in the global scope...

'Course I only have *ONE* or *TWO* at most in the first place, so I
guess I never have any question about what's in the global scope...

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