/**
* 展示反射在get,set上的用法
* 实际是:把对象传入反射类后,调用反射类,获取对象的属性
*/classperson{public$name;public$age;publicfunctionsay(){echo$this->name."<br>".$this->age;}publicfunctionset($name,$value){echo'set name to value';$this->$name=$value;}publicfunctionget($name){if(!isset($this->$name)){echo'unset name';$this->$name='seting~~~';}return$this->$name;}}$stu=newperson();function_getProperties($cur_obj){$reflect=newReflectionObject($cur_obj);return$reflect->getProperties();}functionsetProperty($cur_obj,$propertie_name='',$propertie_value=''){$reflect=newReflectionObject($cur_obj);if($reflect->hasProperty($propertie_name)){$cur_obj->$propertie_name=$propertie_value;}else{thrownewException('没有这个属性,请检查名称',1);}}functiongetProperty($cur_obj,$propertie_name=''){$reflect=newReflectionObject($cur_obj);if($reflect->hasProperty($propertie_name)){echo$cur_obj->$propertie_name;}else{thrownewException('没有这个属性,请检查名称',1);}}setProperty($stu,'name','my_name from property');getProperty($stu,'name1');