Here is the example code of multilevel inheritance in PHP
class Animal {
public $name;
public $species;
function __construct($name, $species) {
$this->name = $name;
$this->species = $species;
}
function eat() {
echo $this->name . " is eating<br>";
}
function sleep() {
echo $this->name . " is sleeping<br>";
}
}
class Mammal extends Animal {
function nurse() {
echo $this->name . " is nursing<br>";
}
}
class Reptile extends Animal {
function sunbathe() {
echo $this->name . " is sunbathing<br>";
}
}
class Dog extends Mammal {
function bark() {
echo $this->name . " is barking<br>";
}
}
class Snake extends Reptile {
function hiss() {
echo $this->name . " is hissing<br>";
}
}
I Hope it will Help you. Thank You.
For more refer link: https: