Interface
Defines an interface class, and its subclass must be implemented. An interface is a template of a class. Its subclass must implement all methods defined in the interface.
Interface User {
Function getHeight ($ height );
Function getWeight ($ weight );
}
Class my implements User {
Function getHeight ($ username ){
Echo $ height;
}
Function getWeight ($ weight ){
Echo $ weight;
}
}
Abstract
Abstract classes extract the class image part, that is, writing repeated items to abstract classes to reduce the workload. As long as the method does not use abstract declaration, it does not need to be implemented in its subclass. In the subclass, this method is a public method.
Abstract User {
Abstract function getHeight ($ height );
Function getWeight (){
Echo $ weight;
}
}
Class my extends User {
Function getHeight ($ height ){
Echo $ height;
}
Function getInfoById ($ id ){
$ This-> getWeight. "<br/> ";
Echo $ id;
}
}