我正在尝试在 codeacademy 上学习 PHP OOP,我想我快疯了。我已经以各种方式将我的代码与示例代码进行了比较,但它就是行不通!请帮助我了解这里出了什么问题,当我尝试从对象 $student 中回显年龄属性时,该对象由 Person 类制成
<?php
class Person {
public $isAlive = true;
public $firstname;
public $lastname;
public $age;
public function __contruct($firstname, $lastname, $age)
{
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->age = $age;
}
}
$teacher = new Person("boring", "12345", 12345);
$student = new Person('hans', 'hansen', 24);
$me = new Person('boring', '12345', 12345);
echo $student->age;
?>