1 _name=$_name; 12 }13 public abstract function getName();14 }15 16 class Book extends Goods{17 public $_author;18 19 //实现其父类的方法体20 public function getName(){21 $this->_name=$_name;22 $this->_author=$_author;23 24 }25 }26 27 class Phone extends Goods{28 public $_brand;29 //实现其父类的方法体30 public function __construct($_name, $_brand){31 parent::__construct($_name);32 $this->_brand=$_brand;33 }34 35 public function getName(){36 $this->_name=$_name;37 $this->_brand=$_brand;38 }39 }40 41 //实例化对象42 $book = new Book('php从入门到精通','mingrikeji');43 $book->getName();44 $p = new Phone('aa','aa');45 $p->getName();