Inheritance in PHP

In this tutorial, you will learn about inheritance in PHP and its uses in PHP for reusing the code to save time and complexity.



Inheritance is used to inherit the definition/characteristics of parent class using extends clause to the child class

 

Types of Inheritance

  1. Single Inheritance
  2. Multilevel Inheritance
  3. Hierarchical Inheritance

 

1.Single Inheritance


 



2. Multilevel Inheritance

 

3. Hierarchical Inheritance

 

Note: PHP does not support Multiple Inheritance.

 



What are the advantages of Inheritance?

  1. It reduces the Complexity of the Code
  2. Reuse of the Code
  3. Enhance Code redablity

 

Tags: , , ,