Re: $this->value VS $value

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

 



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

[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