3.6. PHP OOP - Inheritance
PHP - What is Inheritance?
A concept of accessing the features of one class from another class called Inheritance. The child class will inherit all the public and protected properties and methods from the parent class. An inherited class is defined by using the extends keyword.
PHP - Overriding Inherited Methods
Inherited methods can be overridden by redefining the methods in the child class.
Here the __construct() and intro() methods in the child class (Strawberry) will override the __construct() and intro() methods in the parent class (Fruit):