Re: Re: self:: vs this

From: Date: Sun, 13 May 2007 05:54:36 +0000
Subject: Re: Re: self:: vs this
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-254870@lists.php.net to get a copy of this message
On Fri, May 11, 2007 12:28 pm, Eric Butera wrote: > On 5/11/07, M.Sokolewicz <tularis@php.net> 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?

« previous php.general (#254870) next »