What is inheritance in php?
- Inheritance is properties of PHP.
- Accessing the feature of one class of another class.
- Three types that is single, multiple and multilevel inheritance.
- It is the four pillars of oops.
- It allows a class to reuse the code from another class without duplicating it.
- Two classes one is base/main another one is derived class.
- Base class only use its own function but in Derived class it use both function base or derived class.
How to use inheritance in php?
class school {
}
class students extends school {
}
$sch =new school (); // only use class school
$stu = new students (); // use both class school students (properties and methods)