Inheritance
Inheritance
When a class is defined by inheriting the existing function of a parent class then it is called inheritance. Here child class will inherit all or a few member functions and variables of a parent class. We can define an inherited class by using the extends keyword.
Inheritance has three types Single, Multiple and Multilevel Inheritance but PHP only supports single inheritance, where only one class can be derived from a single parent class.
Example:
Output:
Final Keyword
The final keyword can be used to prevent method overriding or to prevent class inheritance.
Example: