php5.3.1 support multiple inheritance?

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.