Abstract class:
1) A class that contains at least one abstract function. In other words, any class has only one or more abstract methods, and this class is an abstract class.
2) There can be specific methods in an abstract class, and you can have member variables .
3) Abstract classes cannot be instantiated . is called abstract, but also how to instantiate. 2333.
4) Usage:
abstract class father{
the protected (or public modifier cannot be private or the subclass cannot get it) abstract function func1 ();
}
When implementing an abstract method that inherits to
Class Son extends father{// as with normal classes, a subclass can inherit only one abstract class
Public (remove abstract keyword) function func1{
Echo ' must implement all the abstract methods ';
}
}
Interface (interface):
1) All of the interfaces are abstract methods . (because it is intended to be implemented for subclasses.) So it's all public. )
2) There can be no specific method in the interface, and there can be only member constants .
3) A class can implement multiple interfaces .
3) Usage: implements the keyword to implement multiple interfaces separated by commas.
Class Son implements INTERFACEA,INTERFACEB,INTERFACEC {
1. Implement all the abstract methods of these three interfaces, 2. To exactly match the parameters of the abstract method 3. The constants of an interface cannot be overwritten .
}
Abstract class, interface definition in PHP