class GrandFather { public function pocketMoney() { return 'Take this 1000 $'; } } class Father extends GrandFather { public function myIncome() { echo "My father told ".parent::pocketMoney(); } public function myExpense() { return 'Take this 500 $
'; } } class Elder extends Father { public function myEarning() { echo "Father told me ".parent::myExpense(); } } class Younger extends Father { public function myEarning() { echo "Father told me ".parent::myExpense(); } } $elder = new Elder(); $elder->myEarning(); // output Father told me Take this 500 $ $younger = new Younger(); $younger->myEarning(); // output Father told me Take this 500 $
Friday, February 21, 2014
PHP oops Hybrid Inheritance Example
Labels:
php oops
Subscribe to:
Post Comments (Atom)
It was really a nice post and i was really impressed by reading this
ReplyDeleteRuby on Rails Online Course India