<?php
class A {
function example() {
echo "I am A::example() and provide basic functionality.<br />\n";
}
}
class B extends A {
function example() {
echo "I am B::example() and provide additional functionality.<br />\n";
parent::example();
}
}
$b = new B;
// This will call B::example(), which will in turn call A::example().
$b->example();
// SaĆda:
// I am B::example() and provide additional functionality.
// I am A::example() and provide basic functionality.
PD9waHAKCmNsYXNzIEEgewogICAgZnVuY3Rpb24gZXhhbXBsZSgpIHsKICAgICAgICBlY2hvICJJIGFtIEE6OmV4YW1wbGUoKSBhbmQgcHJvdmlkZSBiYXNpYyBmdW5jdGlvbmFsaXR5LjxiciAvPlxuIjsKICAgIH0KfQoKY2xhc3MgQiBleHRlbmRzIEEgewogICAgZnVuY3Rpb24gZXhhbXBsZSgpIHsKICAgICAgICBlY2hvICJJIGFtIEI6OmV4YW1wbGUoKSBhbmQgcHJvdmlkZSBhZGRpdGlvbmFsIGZ1bmN0aW9uYWxpdHkuPGJyIC8+XG4iOwogICAgICAgIHBhcmVudDo6ZXhhbXBsZSgpOwogICAgfQp9CgokYiA9IG5ldyBCOwoKLy8gVGhpcyB3aWxsIGNhbGwgQjo6ZXhhbXBsZSgpLCB3aGljaCB3aWxsIGluIHR1cm4gY2FsbCBBOjpleGFtcGxlKCkuCiRiLT5leGFtcGxlKCk7CgovLyBTYcOtZGE6Ci8vIEkgYW0gQjo6ZXhhbXBsZSgpIGFuZCBwcm92aWRlIGFkZGl0aW9uYWwgZnVuY3Rpb25hbGl0eS4KLy8gSSBhbSBBOjpleGFtcGxlKCkgYW5kIHByb3ZpZGUgYmFzaWMgZnVuY3Rpb25hbGl0eS4=