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

Objects in PHP Forum

View Course » View Exercise

1305 points
53d8054052f863e8bb00006a_709938798
Submitted by
Javis Sullivan
over 3 years ago

Correct output won't pass. Objects 1 4/10

I am getting the correct output in the console but Codecademy keeps showing the error:

"Oops, try again. Did you add the '$firstname', '$lastname' and '$age' properties?"

<?php 
             class Person {
                public $isAlive = true;
                public $firstName;
                public $lastName;
                public $age;


                }
            $teacher = new Person();
            $student = new Person();
            echo $teacher->isAlive;

        ?>

0 votes

Best answer

permalink

Hmm retyped everything in and it worked?

Edit: Realized what I did. I was using camelCase initially for the firstName and lastName variables. And even though it should work in theory, hence the correct output in the console, Codecademy's interpreter wants you to type exactly what's in the prompt.

So they should have been:

$firstname;
$lastname;

// not

$firstName;
$lastName;

Ahh tricky tricky.

1305 points
53d8054052f863e8bb00006a_709938798
Submitted by
Javis Sullivan
over 3 years ago