子类重写父类方法

class Goods{
    public $goods_name;
    public function __construct($g_name){
        $this->goods_name = $g_name;
    }
}
class Book extends Goods{
    public $author;
    public function __construct($g_name,$a_name){
        parent::__construct($g_name);
        $this->author = $a_name;
    }
}

$book = new Book('商品','作者');
var_dump($book);

 

 

posted on 2018-12-08 15:23  薇薇123456  阅读(112)  评论(0编辑  收藏  举报

导航