PHP interface and reference interface. 1. interface introduction and creation Keywords: interface2. interface reference and specification Keywords: implements Interface: a special abstract class with all member attributes being abstract, in the same procedure, 1. interface introduction and creation
Keyword: interface
2. Interface references and specifications
Keyword: implements
Interface: A special abstract class whose member attributes are all abstract. it serves as a standard in a program.
1. all classes are abstract methods.
2. you do not need to add abstract
3. the interface abstract method property is public.
4. the member attribute must be a constant.
Abstract:
1. there must be at least one abstract method in the class.
2. add abstract before the abstract method
Commonalities:
1. they cannot be instantiated and must be inherited or referenced.
2. After inheritance or reference, you must overload all abstract methods before using them.
The interface has its own creation keyword: The interface is similar to the normal class creation
Interface demo {
Const NAME = "NAME ";
Function Fun1 (); // all object methods are abstract methods. you do not need to add adstract
Function Fun2 ();
}
You can use the keyword implements to separate multiple references using commas.
1. common class reference interface example:
Class mypc implements demo, demo2, demo3 {
......
}
2. example of an abstract class reference interface:
Abstract class mypc implements demo, demo2, demo3 {
......
}
3. example of inheriting the parent class reference interface:
Class mypc extends root implements demo, demo2, demo3 {
......
}
4. interface and interface inheritance:
Interface demo3 extends demo {
......
}
Keyword: interface 2. interface reference and standard keyword: implements interface: a special abstract class with all member attributes...