<?php
class Animal{
public $name;
public $color;
public function __construct($color){
$this->color=$color;
}
Funktion write($name){
echo $this->name=$name. „Kann schreiben!“;
}
function run($name){
echo $this->name=$name. " Kann rennen!";
}
}
$dog=new Animal("yellow");
$dog->write("Dog");
echo '<br/>' ;
$sheep=new Animal("white");
$sheep->run("Sheep");
echo '<br/>';
echo " Schaffarbe ist ".$ Sheep->$color; //这行报错,该怎么调用$color这个属性?
?>
$sheep->color,不要color前面的$
echo " sheep color is ".$sheep->color; //这行这样写 $存在的话color就成了未定义的变量?