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

Objects in PHP Forum

View Course » View Exercise

743 points
Submitted by
about 3 years ago

Objects in PHP 6/10

I need help... I can't find my mistake.. :(

class Person {
public $isAlive = true;
public $firstname;
public $lastname;
public $age;
public function greet() {
return "Hello, my name is ".$this->firstname." ".$this->lastname.". Nice to meet you! :-)";

  public  function __construct($firstname, $lastname, $age) {
    $this->firstname = $firstname;
    $this->lastname = $lastname;
    $this->age = $age;

  $teacher = new Person("boring", "12345", 12345);
  $student = new Person("Mike", "Ruderisch", 16);
  echo $teacher->isAlive;
  echo $student->age;
  echo $student->greet();
  echo $teacher->greet();


0 votes


Hi Mike,

Your code worked fine for me. If refreshing the page doesn't work for you, could you tell me what the error message you're getting says?

2835 points
Submitted by
Zeke Y
almost 3 years ago

0 votes


hey in the return line please compare this code
return"hello my name is" .$this->firstname."".$this->$lastname."nice to meet you!:)".; you will find mistake if not please refresh the page

111 points
Submitted by
almost 3 years ago