I am getting an error displayed in calling my $dog2
method greet()
that is undefined variable but I can't understand where I am making a mistake. Please help me :)
<?php
class Dog{
public $numLegs=4;
public $name;
public function __construct($name){
$this->name=$name;
}
public function bark(){
return "woof";
}
public function greet(){
return $name." is very beatifull dog hmmm";
}
}
$dog1= new Dog("Barker");
$dog2= new Dog("Amigo");
echo $dog1->bark();
echo $dog2->greet();
?>