初学php,今天看代码时有一个问题,求助各位,感谢先。。代码如下:
class Example {
private $catalog = array();
public function SetProperties( $arrayVariables ) {
foreach ( $arrayVariables as $name => $value ) {
$this->SetProperty( $name, $value );
}
}
public function SetProperty( $name, $value ) {
$this->$name = $value;
$this->catalog[] = $name;
}
public function GetProperties( ) {
$result = array();
foreach ( $catalog as $name ) {
$result[$name] = $this->GetProperty( $name );
}
return( $result );
}
public function GetProperty( $name ) {
return ( $this->$name );
}
}
上面代码中Example类中的SetProperty函数中的
$this->$name = $value;
这个$name变量并没有在Example类中定义,是为什么?


最新回复