Home > Backend Development > PHP Problem > Why can't php instantiate the interface?

Why can't php instantiate the interface?

Guanhui
Release: 2023-02-28 22:38:01
Original
3333 people have browsed it

Why can't php instantiate the interface?

Why can't PHP instantiate the interface?

Interface interface is a rule and is used for implementations, so it cannot be instantiated directly. If you want to To instantiate, other classes need to implement it, and all methods defined by the interface must be implemented before instantiation can be carried out.

Interface interface introduction

Interface is a keyword for interface operations in object-oriented programming languages. Its function is to combine required members to encapsulate certain functions. gather. It is like a template in which the members that an object must implement are defined, through a class or structure. The interface cannot be instantiated directly, that is, ICount ic=new iCount() is wrong. The interface cannot contain any code for the members, only the members themselves are defined. The specific code for interface members is provided by the class that implements the interface. Interfaces are declared using the interface keyword.

The above is the detailed content of Why can't php instantiate the interface?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template