1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
class A { public function myage() { return ' age is 80'; } } class B extends A { public function mysonage() { return ' age is 50'; } } class C extends B { public function mygrandsonage() { return 'age is 20'; } public function myHistory() { echo "Class A " .$this->myage(); echo "Class B ".$this-> mysonage(); echo "Class C " . $this->mygrandsonage(); } } $obj = new C(); $obj->myHistory(); Output => Class A age is 80Class B age is 50Class C age is 20 |
Leave a reply