Friday, February 21, 2014

PHP oops Hierarchical Inheritance Example




class Father
{
	public function pocketMoney()
	{
		return  'Take this 500 $';
	}

}

class Elder extends Father
{
		
	public function myEarning()
	{
		echo "Father told me ".parent::pocketMoney();

	}

}

class Younger extends Father
{
	public function myEarning()
	{
		echo "Father told me ".parent::pocketMoney();

	}

	
}


$elder = new Elder();

$elder->myEarning();  // output Father told me Take this 500 $

$younger = new Younger();

$younger->myEarning();  // output Father told me Take this 500 $


7 comments:

  1. This is single inheritance connected in parallel keeping the base class common.perfect explanation hierachical inheritance.its very useful.thanks for your valuable information.list of java training institutes in chennai | top 10 java training institutes in chennai

    ReplyDelete
  2. Were a gaggle of volunteers as well as starting off a brand new gumption within a community. Your blog furnished us precious details to be effective on. You've got completed any amazing work!
    Digital Marketing Training in Chennai

    Digital Marketing Training in Bangalore

    ReplyDelete
  3. Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
    python training institute in chennai
    python training in Bangalore
    python training in pune

    ReplyDelete
  4. Your story is truly inspirational and I have learned a lot from your blog. Much appreciated.

    java training in chennai | java training in bangalore

    java online training | java training in pune

    ReplyDelete
  5. This is a terrific article, and that I would really like additional info if you have got any. I’m fascinated with this subject and your post has been one among the simplest I actually have read.
    angularjs-Training in pune

    angularjs-Training in chennai

    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    ReplyDelete
  6. I likable the posts and offbeat format you've got here! I’d wish many thanks for sharing your expertise and also the time it took to post!!
    Microsoft Azure online training
    Selenium online training
    Java online training
    Java Script online training
    Share Point online training

    ReplyDelete