suchen

Heim  >  Fragen und Antworten  >  Hauptteil

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

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

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


高洛峰高洛峰3065 Tage vor785

Antworte allen(1)Ich werde antworten

  • 三叔

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

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

    Antwort
    0
  • StornierenAntwort