왜 결과가 5가 아니라 2인가요?
<code>class a{ public $age=2; public function __constrator(){ $this->age=$age+3; } } $k=new a(); echo $k->age;</code>
왜 결과가 5가 아니라 2인가요?
<code>class a{ public $age=2; public function __constrator(){ $this->age=$age+3; } } $k=new a(); echo $k->age;</code>
너무 웃겼어요 __constrator
가 __construct
, $this->age=$this->age+3;
<code>class a{ public $age=2; public function __constrator(){ $this->age=$this->age+3; // 这里 } } $k=new a(); echo $k->age;</code>
이것은 $this가 없습니다->
<code> $this->age=$this->age+3;</code>