A Method to the Madness


#1

I keep getting this error when I try to Save & Submit Code: Hey, did you forget add my name as a property to the object? :-P. And I’ve checked it 1000000 times and I can’t find any errors at all, I even checked the Q&A Forum, please tell me if you see any errors!

    <?php
    class Person {
    public $isAlive = true;
    public $firstname;
    public $lastname;
    public $age;
    public function __construct($firstname, $lastname, $age) {
        $this->firstname = $firstname;
        $this->lastname = $lastname;
        $this->age = $age;
        }
    public function greet() {
        return "Hello, my name is " . $this->firstname ." ". $this->lastname . ". Nice to meet you! :-)";
         }
    }
     $teacher = new Person("Henrik", "Jørgensen", 37);
     $student = new Person("Alexander", "Charpentier", 16);
     echo $teacher->isAlive;
     echo $teacher->greet();
     echo $student->greet();
    ?>