use interface in PHP

Tram Ho

Interface

➔ Interface in object oriented is a template, which allows us to create a framework for one or more objects

➔ Looking at the interface, we can completely determine which methods and fixed attributes (or constants) are present in the object that implements it.

➔ Syntax:

Interface properties

➔ Interface is not an object

➔ In the interface we are only declaring methods, not defining them.

◆ In the interface we can declare a constant but can not declare the variable.

◆ An interface can not be initialized (because it is not an object).

◆ Implement interface classes must declare and redefine the methods contained in that interface.

◆ A class can implement multiple interfaces.

◆ Interfaces can inherit each other.

Use Interface

➔ Create interface

➔ Create class implements interface

➔ The class defines the contents of the functions

Use Interface

Use Interface

➔ Create interface

➔ Create interface inheritance interface

Share the news now

Source : Viblo