我在调用未定义变量的$dog2
方法时显示错误greet()
,但我不明白我在哪里犯了错误。请帮我 :)
<?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();
?>