<?php class MyObject { function myMethod() { echo "Standard Functionality\n"; } } class MyOtherObject extends MyObject { function myMethod() { echo "New Functionality"; parent::myMethod(); } } $obj = new MyOtherObject(); $obj->myMethod();
<?php class MyObject { static function myMethod() { static::myOtherMethod(); } static function myOtherMethod() { echo "called from MyObject"; } } class MyOtherObject extends MyObject { static function myOtherMethod() { echo 'called from MyOtherObject'; } } MyOtherObject::myMethod();
<?php class MyObject { function myBaseMethod() { echo "I am declared in MyObject\n"; } } class MyOtherObject extends MyObject { function myExtendedMethod() { echo "myExtendedMethod is declared in MyOtherObject\n"; self::myBaseMethod(); } } $object = new MyOtherObject(); $object->myExtendedMethod();