🚀 DevOps Certified Professional
📅 Starting: 1st of Every Month 🤝 +91 8409492687 | 🤝 +1 (469) 756-6329 🔍 Contact@DevOpsSchool.com

Inheritance in PHP

DevOps

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

The process of deriving or making a new class from old class is known as inheritance .

syntax for decleration of child or new class :-

class childClassName extends ParentClassName
{
    
        statement ;
    
}

Benifits of inheritance in PHP
  1. The code is being re-used from one class to another. We need not required to re-write the same thing again and again.
  2. Extensibility is one of the advantages of the inheritance in which we can extend the base class feature without making little or no changes to fulfill the business requirements.
  3. we don’t have to describe similar property or method in upcoming class we can extends all the property of parent class using inheritance.

Types of Inheritance

  1. Single Inheritance
  2. Multi-layer inheritance
  3. hierarchical inheritance

  • Single Inheritance
  • If single class is derived or made from one parent or old class is known as Single Inheritance

    eg:-

  • Multi-layer inheritance
  • In the multi-level inheritance, we will inherit the one base class into a derived class, and then the derived class will become the base class for another derived class.

    Inheritance in php

  • hierarchical inheritance
  •  In the hierarchical inheritance, we will inherit the one base class into multiple derived classes.