Co-Authored By:

Asked by: Genova Matthie
technology and computing programming languagesWhat is inheritance in PHP with example?
Thereof, how does inheritance work in PHP?
PHP 5 Inheritance. In object orientedprogramming, Inheritance enables a class to use propertiesand methods of an existing class. The class which isinherited is called Parent class(or super class or baseclass) while the class which is inheriting other class is called asChild class(or sub class or derived class).
Also to know is, what are the types of inheritance in PHP?
Types of PHP Inheritance Generally, inheritance has three types,single, multiple and multi-level inheritance. But,PHP supports single inheritance and multi-levelinheritance. That means the subclass will be derived from asingle parent class.
Inheritance is a mechanism in which one classacquires the property of another class. For example, a childinherits the traits of his/her parents. Withinheritance, we can reuse the fields and methods of theexisting class. Hence, inheritance facilitates Reusabilityand is an important concept of OOPs.