Dan Cech wrote:
Morgan Craft wrote:
Any reason why I should use $this->methodName() over self::methodName() Or is the self::methodName() reserved only for working within a static
method?

The deciding factor is the nature of methodName()

self::methodName() if methodName is static
$this->methodName() if methodName is not static

One interesting twist, self::methodName is not inherited:


Of course, it is as expected. $this-> refers to the instantiated object -- in the previous example that object was of subclass. Whereas self:: refers to the class in which it occurs -- which, for the this_self() method in parentclass, was parentclass.

Good point, though, Dan. It certainly tripped me up before I thought about it.

Jeremy
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to