self:: , parent:: and static:: are special cases. They always act as if you made a non-static call and also supported calls to static methods without throwing E_STRICT .
You will only have problems using class names instead of these relative identifiers.
So what will work:
class x { public function n() { echo "n"; } } class y extends x { public function f() { parent::n(); } } $o = new y; $o->f();
and
class x { public static function n() { echo "n"; } } class y extends x { public function f() { parent::n(); } } $o = new y; $o->f();
and
class x { public static $prop = "n"; } class y extends x { public function f() { echo parent::$prop; } } $o = new y; $o->f();
But what does not work:
class x { public $prop = "n"; } class y extends x { public function f() { echo parent::prop; } }
You should still explicitly access properties using $this .
bwoebi
source share