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

Objects in PHP Forum

View Course » View Exercise

826 points
543303a68c1cccd674000009_312218933
Submitted by
Daniel
almost 3 years ago

It gives me a syntax error but it says that I can move on???

Here is my error:
Parse error: syntax error, unexpected TVARIABLE, expecting TFUNCTION on line 11

Here is my code:
<!DOCTYPE html>


Reconstructing the Person Class




<?php
class Person {
$teacher=new Person();
$student=new Person();
public $isAlive = true ;
public $firstname;
public $lastname;
public $age;

      echo teacher.isAlive;
   }
   ?>
  </p>
</body>

0 votes

permalink

<?php

class Person {
public $isAlive = true;
public $firstname;
public $lastname;
public $age;
}
$teacher = new Person();

You want to create an instance of the class outside of the class declaration.

130 points
Df985d7d832006621a8c634ceda9489d?s=140&d=retro
Submitted by
Jim Tryon
almost 3 years ago