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

Objects in PHP Forum

View Course » View Exercise

554 points
553ffdcd9113cba9ef0000e8_445393942
Submitted by
Joseph Kwami Azalekor
about 2 years ago

Please I need a SOLUTION to my error(s).............

<!DOCTYPE html>


Reconstructing the Person Class




<?php
class Person {
$teacher = new Person();
$student = new 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;
            }
        }
        $teacher = new Person ("boring", "12345", 12345);
        $student = new Person("Joseph", "Azalekor", 20);
        echo $student->age;
        echo $student->isAlive;
    ?>
  </p>
</body>

1 vote

permalink

Here you are:

you should have this:

echo $teacher->isAlive; 
echo $student->age;

instead of this:

    echo $student->age;
    echo $student->isAlive;

Every thing else is good.

2283 points
A86f7a545bb298e9d17b1b0ba5ae2a31?s=140&d=retro
Submitted by
Sergeant Shift
about 2 years ago

2 Comments

553ffdcd9113cba9ef0000e8_445393942 Joseph Kwami Azalekor about 2 years ago

thanks so much;
little mistakes.....................

A86f7a545bb298e9d17b1b0ba5ae2a31?s=140&d=retro Sergeant Shift about 2 years ago

welcome