search

Home  >  Q&A  >  body text

用了构造函数为什么这个还是2?

结果为什么是2而不是5?

class a{    public $age=2;    public function __constrator(){       $this->age=$age+3;
    }
    
}$k=new a();echo $k->age;


高洛峰高洛峰3063 days ago776

reply all(1)I'll reply

  • 三叔

    三叔2016-10-22 13:23:48

    笑死我了 __constrator 变成 __construct 以及 $this->age=$this->age+3;

    reply
    0
  • Cancelreply