class class_name
{
var $attribute;
function __get($name)
{
return $this -> $name;
}
function __set($name,$value)
{
$this -> $name = $value;
}
}
$a = new class_name();
$a -> attribute = 5;//__set()設置屬性值
$a -> attribute; //__get()檢查屬性值