<?php
class Person
{
private $name;
private $age;
public function __get($property_name)
{
echo "自动调用__get()方法获取属性值<br>";
if(isset($this->$property_name))
{
return($this->$property_name);
}
else
{
return (NULL);
}
}
public function __set($property_name,$value)
{
echo "自动调用__set()方法获取属性值<br>";
$this->$property_name = $value;
}
}
$p = new Person();
$p->name = "张三";
echo $p->name."你真是个傻逼啊你!!!";
?>
目前暂无任何回答
- 0 回答
- 0 关注
- 101 浏览
添加回答
举报
0/150
提交
取消