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

Objects in PHP Forum

View Course » View Exercise

135 points
Picture
Submitted by
Yannick Boers
about 2 years ago

5/10 I really don't get what I'm doing wrong

What am I doing wrong? Could someone explain it elaborately? Thank you so much!

<!DOCTYPE html>
    <html>
        <head>
          <title>Reconstructing the Person Class</title>
          <link type='text/css' rel='stylesheet' href='style.css'/>
        </head>
        <body>
          <p>
            <?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;
      }
    }
      $teacher = new Classname("boring", "12345", 12345);
      $student = new Classname("Yannick", "Boers", 20);
      echo $teacher->isAlive;
      echo $student->age;


            $teacher = new Person();
            $student= new Person();

            echo  $teacher->isAlive;
            ?>
          </p>
        </body>
    </html>

3 votes

permalink

You have typed the following:
$teacher = new Classname("boring", "12345", 12345);
$student = new Classname("Yannick", "Boers", 20);

Your class is called Person - so try with this(I'm not sure if it helps):
$teacher = new Person("boring", "12345", 12345);
$student = new Person("Yannick", "Boers", 20);

245 points
0d1456c5f147b3037229bc4ec03b2012?s=140&d=retro
Submitted by
Falcken
about 2 years ago

4 Comments

Picture Yannick Boers about 2 years ago

I will try it out right away! Thanks:)

0d1456c5f147b3037229bc4ec03b2012?s=140&d=retro Falcken about 2 years ago

Did it help? :-)

Picture Yannick Boers about 2 years ago

yes! Thank you:)

55e7642086f55250390004dc_31640069 MissPotato201 about 2 years ago

actually Yannick's code worked for me