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

Objects in PHP Forum

View Course » View Exercise

474 points
Submitted by
over 3 years ago

General Question

Hello! So I was working on 9/10 and I passed it but what i didnt understand is when I tried to echo $cat1 it didnt show in the console. Is it a bug? Or is it my code?
Here is my code.
class Cat {
public $isAlive = true;
public $numLegs = 4;
public $name;
public function __construct($name) {
$this->name = $name;
public function meow() {
return "" . $this->$name . "Meow meow";

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

Thank you.

3 votes


in the meow method you wrote " $this->$name " , remove the $ for the name. just like this ---> " $this->name ".
hope it works :)

850 points
Submitted by
over 3 years ago

1 Comment

0edcc6fe3cf795eb6e9c63b649283a2c?s=140&d=retro andrewnoelcasper over 3 years ago

Thanks :)