Re: Re: self:: vs this

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

 



On Fri, May 11, 2007 12:28 pm, Eric Butera wrote:
> On 5/11/07, M.Sokolewicz <tularis@xxxxxxx> wrote:
>> statically:
>> Class Foo {
>>     static $a = 1;
>>     static function Bar() {
>>        self::a++;
>>     }
>> }

Use self:: only when you don't have an actual instance handy, is a
general rule, I think...

self:: is kinda like using the Plato-like "ideal" of the class --
there's no actual instantiated real-world "thing" to work on.

You're working with an abstract non-existant idealized non-object.

$x (or $this) you are working with an actual real-life instantiated
"object".

Disclaimer:
This is how I thought of it in C++, rather than a ton of experience in
PHP...

PS
PHP 6 may become more "strict" about using / not using self:: where it
"should" be used...  Depends on how the Internals 'discussions' pan
out...

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