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

Objects in PHP Forum

View Course » View Exercise

763 points
Ec9d8e972ca1e17a5785b7756ebc728e?s=140&d=retro
Submitted by
Taterjr
about 2 years ago

8/10 Oops, try again. Where is your 'bark' method?

what is wrong with my code:
class Dog {
public $numLegs = 4;
public $name;
public function __construct($name) {
$this->name = $name;
}
public function bark() {
return "Woof!";
}
public function greet() {
return "Woof " . $this->name . " woof!";
}
}
$dog1 = new Dog("Barker");
$dog2 = new Dog("Amigo");

    echo $dog1->bark();
    echo $dog2->greet();

0 votes

permalink

}
$dog1 = new Dog("Barker");
$dog2 = new Dog("Amigo");

you forgot the ; on the end then it should work

394 points
0d362003b7e02c1c611e4a6789f9615d?s=140&d=retro
Submitted by
Martijn
about 2 years ago

1 Comment

0d362003b7e02c1c611e4a6789f9615d?s=140&d=retro Martijn about 2 years ago

};
$dog1 = new Dog("Barker");
$dog2 = new Dog("Amigo");