interface
defines an interface class, and the methods in it must be implemented by subclasses. An interface is a template for a class, and its subclasses 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 class extracts the analogous part, Just write repetitive things into abstract classes to reduce the workload. As long as the method is not declared abstract, it does not need to be implemented in its subclasses. And this method is a public method in the subclass.
abstract User{
abstract function getHeight($height);
function getWeight(){
echo $weight;
}
}
class my extends User{
function getHeight($height){
echo $height;
}
function getInfoById($id){
$this->getWeight."
";echo $id;
}
}