Previously, PHP does not support multiple inheritance, and can now support multiple inheritance
In the course of learning, there is no intention to discover the following phenomena
Class a{
function X () {
echo ' Y ';
}
function Test () {
echo "DF";
}
}
Class B extends a{
function Y () {
Echo parent::x ();
}
}
Class C extends b{
function Z () {
Echo Parent::y ();
}
}
$c = new C ();
$c->x ();
$c->test ();
?>
Output Result: YDF
Reply to discussion (solution)
It's not called multiple inheritance.
Ah, that's it. But the old PHP didn't seem like a grandson to inherit Grandpa's? Rookie ask Ah haha ...
See the egg ache ~ thought PHP really can inherit more!!
PHP does not support multiple inheritance, support single inheritance, if it is necessary to implement multiple inheritance, the tutorial has to use the interface to achieve multiple inheritance.
This is still a single inheritance.
I'm dizzy, is this more than inheritance?
Compared to multiple inheritance, or interface is better
This is the relationship between Grandpa and father's son how to inherit Ah???
I really thought I could achieve multiple inheritance, multiple inheritance is Class A inherits Class B, and also inherits Class C.
This is also called a single inheritance???????? is the title of the party two generations ah.
Multi-inheritance is such as 4 sons inheriting a father's relationship, the sense of mapping, whereas single inheritance is an inherited one, as if linear inheritance, and the last one inherits all previous properties and methods.