PHP Multiple Inheritance with Interfaces

后端 未结 5 1275
醉话见心
醉话见心 2020-12-14 19:39

I\'m trying to understand how using interfaces gives me multiple inheritance as I\'ve been googling.

class A
{
 function do1(){}
 function do2(){}
 function          


        
5条回答
  •  盖世英雄少女心
    2020-12-14 20:01

    As told here by @tonicospinelli, it seems that indeed, PHP allows multiple inheritance of interfaces, but it isn't clearly explained, just given an example

    The way multiple inheritance works, PHP passes these using Traits that implement Interfaces.

    Once you declare a Class implementing a "multi-interface" (1), you may use already defined Traits to assure inheritance is well-performed.

    (1): Saying "multi-interface" I mean a class implementing an interface what extends from multiple other interfaces

提交回复
热议问题