In Multilevel inheritance class inherits from another class, and that class also inherits from another class.
Inheritance happens in multiple levels
Example:
<?php
class Person {
public function showName(){
echo "Name: Rahul <br>";
}
}
class Student extends Person {
public function showCourse(){
echo "Course: BCA <br>";
}
}
class Result extends Student {
public function showResult(){
echo "Result: Pass";
}
}
$obj = new Result();
$obj->showName(); // from Person
$obj->showCourse(); // from Student
$obj->showResult(); // from Result
?>- Person - Parent class
- Student - Child class (inherits Person)
- Result - Grandchild class (inherits Student)