PHP abstract class, interface definition, php abstract class Interface Definition
Abstract class ):
1) includeAt least one abstract Method(Abstract function) class. In other words, any class has only one or more abstract methods. This class is an abstract class.
2) abstract classThere can be specific methods,There can be member variables.
3) abstract classCannot be instantiated. They are all called abstract. How can they be instantiated. 2333.
4) usage:
Abstract class Father {
Protected (or public modifier cannot be private or the subclass cannot be obtained)Abstract function func1 ();
}
When the inherited abstract method is implemented
Class Son extends Father {//Like a normal class, a subclass can inherit only one abstract class.
Public (remove abstract keywords) function func1 {
Echo'All abstract methods must be implemented';
}
}
Interface ):
1) InterfaceAll are abstract methods. (Because it is used to implement sub-classes. So all are public .)
2) InterfaceNo specific method, AndOnly member constants are allowed.
3) A ClassMultiple Interfaces can be implemented.
3) usage:Implement multiple interfaces after the implements keywordSeparated by commas.
Class Son implements InterfaceA, InterfaceB, InterfaceC {
// 1. All the abstract methods that implement these three interfaces; 2. They must be exactly the same as the parameters of the abstract method; 3. The constant of the interface cannot be overwritten.
}