The difference between extend and implements
拉拉韦尔
拉拉韦尔 2020-06-12 17:50:33
0
1
1389
class Test extend Test1
class Test implements Test1

Does anyone have a detailed demo to explain the difference between extend and implements? I don’t understand the online examples in detail.

拉拉韦尔
拉拉韦尔

大牛之路

reply all (1)
青Blue

One is to inherit the parent class. The subclass can only implement some methods in the parent class. The parent class can contain member methods (that is, the function has a function body). A subclass can only inherit one parent class.

The other is to implement an interface. A class can implement multiple interfaces at the same time and inherit a parent class at the same time. During the implementation process, all methods in the interface must be implemented. The interface can only have method names, not Method content (only function name, no function body).

Probably like this

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!