class base{
public $dog = array('color'=>'red','age'=>3);
}
class one extends base{
public function set($key,$value)
{
$this->dog[$key] = $value;
}
}
class two extends base{
public function set($key,$value)
{
$this->dog[$key] = $value;
}
}
$one = new one();
$two = new two();
$one->set('color','yellow');
print_r($one->dog);//Array ( [color] => yellow [age] => 3 )
print_r($two->dog);//Array ( [color] => red [age] => 3 )
想要$one对象改变了dog属性之后,$two对象的dog属性也跟着改变,就要引用的那样,不知道要怎样实现?
static 静态关键字