继承构造方法,自己参考而已。
<?php
class a{
??? protected? $aa;
??? protected $bb;
??? protected function __construct($a,$b){
??? ??? $this->aa=$a;
??? ??? $this->bb=$b;
??? }
???
??? protected function getMessage(){
??? ??? return $this->aa.$this->bb;
??? }
}
class b extends a{
??? private? $cc;
??? public function __construct($a,$b,$c){
??? ??? parent::__construct($a, $b);
??? ??? $this->cc = $c;
??? }
???
??? public function getMessage(){
??? ??? return $this->aa.$this->bb.$this->cc;
??? }
}
$sample = new b(1, 2, 3);
echo $sample->getMessage();