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

Objects in PHP Forum

View Course » View Exercise

1183 points
06c4d778c7d3e68b71a7dbf3f6c68b19?s=140&d=retro
Submitted by
nanotech238
almost 3 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 -->
<?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('boring','12345', 12345);
$student = new Person('John', 'Smith', 677);

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

0 votes

permalink

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

1362 points
68755f7727cf05245ea9134038ce60a0?s=140&d=retro
Submitted by
xelamarie
almost 3 years ago