PHP Inheritance – Multilevel and Multiple Inheritance in PHP

PHP Inheritance – Multilevel and Multiple Inheritance in PHP

PHP Inheritance – Multilevel and Multiple Inheritance in PHP

In this Post We Will Explain About is PHP Inheritance – Multilevel and Multiple Inheritance in PHP With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to types of inheritance in php withExample

In this post we will show you Best way to implement multiple inheritance in php with example, hear for single inheritance in php with examplewith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

  PHP Star Triangle Nested using Foreach Loop

Types of PHP Inheritance

PHP does not any way to support multiple inheritance. but PHP supports simple multilevel inheritance.

There are the Following List of PHP Inheritance
1.PHP Single Inheritance
2.PHP multiple Inheritance
3.PHP multi-level Inheritance

multiple inheritance in PHP

 class livedemo
{
//Your simple class body
}
class livedemo1
{
//Your simple class body
}
class livedemo3 extends livedemo1 livedemo2
{
//your simple class body
}

multilevel inheritance in PHP

	
class livegrandParent
{
//Your Body of live grand parent class
}
class liveparent extends livegrandParent
{
//Your Body Of live parent class
}
class livechild extends liveparent
{
//Your Body of live child class
}

PHP oops Multilevel Inheritance Example

class FirstLevel
{
	public function gfAge()
	{
		return  ' salary is 800000';
	}

}

class SecondLevel extends FirstLevel
{
		
	public function fAge()
	{
		return  ' salary is 50000';
	}

}

class ThirdLevel extends SecondLevel
{
	public function sAge()
	{
		return  'salary is 200000';
	}

     public function myHistory()
     {
	 echo "my FirstLevel ".parent::gfAge();
	 echo "my SecondLevel ".parent::fAge();
       echo "my SecondLevel ".$this->sAge();
     }
	
}
$son = new ThirdLevel();

$son->myHistory();
----------------------
// output is

//my FirstLevel salary is 80
//my SecondLevel salary is 50
//my SecondLevel is 20

Example

  Session Management Using Yii Framework

I hope you have Got What is hierarchical inheritance in php with example And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Reply

avatar
  Subscribe  
Notify of