abstract class Goods{
public $name;
public $price;
public function __construct($name,$price)
{
$this->name = $name;
$this->price = $price;
}
abstract public function getName();
public function getPrice(){
return $this->price;
}
}
class book extends Goods{
public $author;
public $publisher;
public function __construct($author,$publisher,$name, $price){
parent::__construct($name, $price);
$this->author=$author;
$this->publisher=$publisher;
}
public function getName(){
return $this->name.$this->price;
}
}
class phone extends Goods{
public $brand;
public $color;
public function getName(){
return $this->name;
}
}
抽象类抽象类在父类在class前+abstract抽象类不能实例化对象抽象类只能被继承使用抽象方法抽象方法是在父类中抽象方法必须在子类重写抽象方法只能声明,不能有实现部分(在父类)重写方法必须要有实现部分(在子类)abstract class Goods{ public $name; public $price; public functio...