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

Objects in PHP Forum

View Course

378 points
Submitted by
Vipul Garg
over 2 years ago

Exercise 8/10 want to know if code is right!

just want to ask that if i wrote the right code or not!

<!DOCTYPE html>

Practice makes perfect!

class Dog
public $numLegs = 4;
public $name;
public function __construct($name)
$this->name = $name;
public function bark()
return "Woof!";
public function greet()
return "My name is". $this->name;
$dog1 = new Dog("Barker");
$dog2 = new Dog("Amigo");
echo $dog1->bark();
echo $dog2->greet();

0 votes


You got it mate! Thumbs up

483 points
Submitted by
over 2 years ago