This forum is now read-only. Please use our new forums at

Objects in PHP Forum

View Course » View Exercise

1183 points
Submitted by
almost 4 years ago

Not getting first & last name Method to the Madness 5/10

Got error free for the codes, but the first name & last name is not showing up. What's the deal? Here is my code:

<!DOCTYPE html>

Reconstructing the Person Class

<!-- Your code here -->
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('boring','12345', 12345);
$student = new Person('John', 'Smith', 677);

    echo $teacher->greet() . '<br/>';
    echo $student->greet();

0 votes


you have one too many underscores in your construct function. delete one and see if that's the issue.

1362 points
Submitted by
almost 4 years ago