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

Objects in PHP Forum

View Course » View Exercise

721 points
5712553a6c20fee9cc00068d_690375042
Submitted by
aweful
about 2 years ago

didn't echo the value of '$teacher->isAlive.

http://screencast.com/t/lqpIVVoqCJow
the link above is a screen shot of my code and the text below is the error message I received:
'Oops, try again. It looks as if you didn't echo the value of '$teacher->isAlive. :-('
What am I doing wrong? It looks correct to me and I reviewed the forum for answers and I've done everything the others say I should do.
My code is below:

<?php ?>
<!-- Your code here -->
class Person {
public $isAlive = true;

       public $firstname;
       public $lastname;
       public $age;
        }

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

    echo $teacher->isAlive;

  </p>

2 votes

permalink

I figured it out. It wouldn't accept the answer with the commented out "<!-- Your code here -->"

Buuaahhhhh

Onward.

721 points
5712553a6c20fee9cc00068d_690375042
Submitted by
aweful
about 2 years ago

3 Comments

Picture Ben Friel about 2 years ago

What do you mean commented out I am having the same problem

0c693cdcd29943e9e8df755856494927?s=140&d=retro Bilszima about 2 years ago

me too

798c10945b825924b8ad1696139db96a?s=140&d=retro bbryant almost 2 years ago

I think the code <!-- Your code here --> is the comment format for HTML, not PHP. I just added // to the statement to make it a comment for PHP which would work for JavaScript as well:
//<!-- Your code here -->


1 vote

permalink

Try to removed the blank spaces.

<!DOCTYPE html>


Reconstructing the Person Class



    <?php

    class Person{
        public $isAlive = true;
        public $firstname;
        public $lastname;
        public $age;
    }

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

    echo  $teacher->isAlive;
    ?>

  </p>
</body>

401 points
68b8b5a7fe82db11adad6c7940a494b1?s=140&d=retro
Submitted by
Wesley
almost 2 years ago