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

Objects in PHP Forum

View Course » View Exercise

713 points
Fa5217826731e5b18c0faac6dbf4327c?s=140&d=retro
Submitted by
TWhite786
about 3 years ago

1.9 Challenge Time: I don't see your constructor, is there a '__construct' function?

<?php
        class Cat {
            public $isAlive = true;
            public $numLegs = 4;
            public $name;

            public function __contruct($name) {
                $this->name = $name;
            }

            public function meow() {
                return "Meow Meow";
            }
        }

        $cat1 = new Cat("CodeCat");
            echo $cat1->meow();
    ?>

Yes....Yes there is.

Someone mind telling me what i'm missing here?


0 votes

permalink

Hi there,

Try refreshing your page, the cache or using a different web browser - your code is passing.

The following errors are things I caught after reading the lesson.

  1. You accidentally misspelled construct

    public function __contruct($name) {

  2. You used "Meow Meow" while the lesson asks for "Meow meow"

Sometimes these lessons are really strict about how we spell things, but in this case, I used your exact code and it's letting me pass. I'm unsure why, but I'm about 90% sure it's a browser problem at this point.

What you can learn from this though, is to make sure you are catching your self in those little mistakes. It's always the smallest things that give us headaches after you write a few hundred lines of code, lol.

Let me know how it goes!

  • Lloan

2651 points
5915ffb1e1281373f9000046_693940620
Submitted by
Lloan Alas
about 3 years ago

2 Comments

Fa5217826731e5b18c0faac6dbf4327c?s=140&d=retro TWhite786 about 3 years ago

Thank you very much, i fixed the construct spelling, and passed!

5915ffb1e1281373f9000046_693940620 Lloan Alas about 3 years ago

Glad to hear that!