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

Objects in PHP Forum

View Course » View Exercise

915 points
5367fc20282ae3fb9b000e73_750480853
Submitted by
Cakefaceasepfibaserg
about 4 years ago

My code is correct but there's still some problem with it

I keep getting this error: Oops, try again! Did you add the '$firstname', '$lastname' and '$age' properties?
Even though it clearly states in the instructions that: Add three further public properties to thePerson class: $firstname, $lastname and $age. Don't assign any values to these.
So i don't understand, am i misunderstanding?
My code:
<?php
class Person {
public $isAlive = true;
public $firstName;
public $lastName;
public $age;
}
$teacher = new Person();
$student = new Person();
echo $teacher->isAlive;
?>


4 votes

permalink

Hi

I think it is cap sensitive, so try to remove the caps from your three public varialbles..

620 points
527b911ff10c60eaa1002b56_189999668
Submitted by
Tripleb
about 4 years ago

8 Comments

5367fc20282ae3fb9b000e73_750480853 Cakefaceasepfibaserg about 4 years ago

nah, i managed to fix it. No idea what the problem was but my code was correct and i had to re-write the damn thing. CodeCademy has another bug :P

Picture Mike Perry about 4 years ago

i had the same problem with this. Although not syntactically correct, this exercise accepted my code if wrote echo $teacher->isAlive; as echo $teacher->isAlive();. Not sure why it wants this because I think the parentheses indicate a method call, and this isn't one. Hope that helps someone else and hopefully codecademy can clarify this

5367fc20282ae3fb9b000e73_750480853 Cakefaceasepfibaserg about 4 years ago

Yeah that helps, thanks

33fea6c67df83561b126e756bbf68a3a?s=140&d=retro kman1234 about 4 years ago

your problem was you had $firstName in cap name suppose to be lower case

523f327680ff33a6d9007123_506687127 Kevin about 4 years ago

Was having the same issue; making the variables all lowercase fixed it. Thanks ;)

527b911ff10c60eaa1002b56_189999668 Tripleb about 4 years ago

yr welcome :)

Picture Stacey Lane over 3 years ago

UGH!!! Same issue. Continuity is important in programming--if one variable is set in camel-case, the others should be as well. Just sayin.

Abbf1a7def6935ed5d07722a70d9f180?s=140&d=retro Christian about 3 years ago

How long has this been an issue codecademy? I'm not saying hire full time staff to run your website but this kind of bush league stuff...I mean...isn't it embarrassing?