Re: $this->value VS $value

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

 



On Tue, Sep 23, 2008 at 6:25 PM, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
> Nathan Nobbe schreef:
>>
>> On Tue, Sep 23, 2008 at 10:41 AM, Micah Gersten <micah@xxxxxxxxxxx> wrote:
>>
>>> Eric Butera wrote:
>>>>
>>>> On Tue, Sep 23, 2008 at 12:26 PM, Jochem Maas <jochem@xxxxxxxxxxxxx>
>>>
>>> wrote:
>>>>>
>>>>> (using $this->foo or MyClass::$foo for static properties).
>>>>>
>>>> also self::
>>>>
>>>>
>>> Actually within a class, I think you must self:: before a static
>>> property or something shows up in the error log.
>>
>>
>> yea, php will think its a local variable if not qualified w/ the self
>> keyword and scope resolution (or w/e its called in php :D), but the name
>> of
>> the class and the scope resolution operator works as well.  its just a
>> hair
>> less flexible because if the class name changes you have to update some
>> code
>> whereas w/ self, the code is no longer dependent upon the class name.
>>
>> /// psuedocode !
>> class A {
>> protected static $someStatic = 5;
>>
>> public function doStuff() {
>>  $someStatic  // php thinks this is a local var
>>  self::$someStatic  // php can id this as a static var
>>  A::$someStatic  // php can id this as a static var
>
> Nathan is correct, I'd like to add that 'self' is actually nothing more than
> a simple alias used at compile time to put the class name in ...
> 'self' literally equates to 'MyClass',  but it saves hassle when refactoring
> and it's much clearer that you mean 'this class Im looking at/working in'
> .... personally whenever I see a classname referenced statically inside a
> method
> I kind of assume it must be another class :-P
>
> ... now had 'self' been late (statically) bound ... no I won't go there, we
> get
> 'static' very soon now :-P
>
>> }
>>
>> -nathan
>>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Active Record sucks :P

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