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

Objects in PHP Forum

View Course » View Exercise

781 points
5291b284f10c6064310013e5_297858218
Submitted by
Ivan Kotora
over 2 years ago

What happend? Exercise 4

Hi I wanna ask for my mistake in the exercise 4. here is my code
<?php
class Person {
public $isAlive = true;
public $fristname;
public $lastname;
public $age;
}
$teacher = new Person();
$student = new Person();
echo $teacher->isAlive;
?>

but still , when I hit Save and Submit, it outputs:
Oops, try again. Did you add the '$firstname', '$lastname' and '$age' properties?


0 votes

permalink

Oh sorry bug fixed $fRIstname

781 points
5291b284f10c6064310013e5_297858218
Submitted by
Ivan Kotora
over 2 years ago


0 votes

permalink

Hi Ivan,
try to add $ sign to isAlive property.

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

164 points
54a0081e95e37823da011956_886820422
Submitted by
Niv Levy
over 2 years ago


0 votes

permalink

hi Niv i tried doing what you said and it worked
thanks so much:)

547 points
55e7642086f55250390004dc_31640069
Submitted by
MissPotato201
over 2 years ago


0 votes

permalink

if you could spell firstname right you would get it lol

473 points
55e7261a51b887d14c0000c6_127035679?awsaccesskeyid=akiajkz7qvqfd72xnj3q&expires=1501228149&signature=fnl%2fraecpyxlqx73hnqf4ddqd6m%3d
Submitted by
Jordan Alexander Wilkey
almost 2 years ago