Home >Backend Development >PHP Tutorial >Why is this still 2 after using the constructor?

Why is this still 2 after using the constructor?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-10-19 10:18:50933browse

Why is the result 2 instead of 5?

<code>class a{
    public $age=2;
    public function __constrator(){
       $this->age=$age+3;
    }
    
}

$k=new a();
echo $k->age;</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn