1.__get($forget)下划线为连续两个。
<?php
class person
{
public $country;
private $name;
private $sex;
private $age;
function __get($forget)
{
return $this->$forget;
if(isset($this->$forget))
{
return($this->$forget);
}
else
{
return(NULL);
}
}
function __set($variable1,$variable2)
{
echo "设置成功\n";
echo "<br>";//输出换行
$this->$variable1 =$variable2;
echo $this->$variable1;
}
function printvariable($somethingforprint)
{
echo $somethingforprint;
}
}
$a=new person();
$a->name="Lily";//
$a->printvariable($a->name);//调用类里面的变量方法
?>