Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use interface in the php interface

Shulou Source: shulou.com Published: 2022-05-31 10:57:02 09月28日 Update

Most people do not understand the knowledge points of this article "how to use interface in the php interface", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use interface in the php interface" article.

1. Description

The methods in the interface are all abstract methods and are public.

2. Interfaces can also inherit interfaces, but subclasses must implement all methods

Interface E extends A {/ / Interface E inherits the method defined in A must be implemented in the interface Aline E.

3. Implement multiple inheritance:

We all know that classes (class) in PHP are single inheritance, so is there no way to implement multiple inheritance? The answer is no. We can implement multiple inheritance of classes in other special ways, such as using interface interface implementation, as long as the characteristics of the class are abstracted into interfaces, and objects have multiple identities by implementing interfaces, so that multiple inheritance can be simulated.

The following is an example of multiple inheritance using an interface (interface). The source code is as follows:

The above is about the content of this article on "how to use interface in the php interface". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about the relevant knowledge, please follow the industry information channel.

Tags: Interfaces contents methods types objects articles methods knowledge articles identities tips special values examples methods can be passed at the same time most of the subclasses that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei Docker MySQL OPPO Reno