php 反射
2016-03-06 22:22
609 查看
//获取对象属性列表 $reflect=new ReflectionObject($student); $props=$reflect->getProperties(); foreach($props as $prop){ print $prop->getName(); } //获取对象方法列表 $m=$reflect->getMethods(); foreach($m as $prop){ print $prop->getName(); } //返回对象属性关联数组 get_object_vars($student); //类属性 get_class_vars(get_class($student)); //返回由类方法名组成的数组 get_class_methods(get_class($student)); //获取对象属性列表所属的类 get _class($student); <?php class mysql{ function connect($db){ echo "连接到数据库${db[0]\r\n}"; } } class sqlproxy{ private $target; function _construct($tar){ $this->target[]=new $tar(); } function _call($name,$args){ foreach ($this->target as $key => $obj) { # code... $r=new ReflectionClass($obj); if($method = $r->getMethod($name)){ if($method->isPublic()&&!$method->isAbstaract()){ echo "方法拦截记录LOG\r\n"; $method->invoke($obj,$args); echo "方法拦截\r\n"; } } } } }
相关文章推荐
- php接收上传文件
- Php安装时出现的问题处理
- yii 命令行模式
- 关于PHP框架
- thinkphp简洁、美观、靠谱的分页类
- thinkphp简洁、美观、靠谱的分页类
- thinkphp简洁、美观、靠谱的分页类
- thinkphp自定义模板标签(二)
- thinkphp自定义模板标签(二)
- thinkphp自定义模板标签(一)
- thinkphp自定义模板标签(一)
- yii 用户管理 配置文件
- yii 用户管理 视图
- yii 用户管理 model
- yii 用户管理 controller
- php关闭浏览器,程序继续执行
- yii框架-依赖注入
- php中使用exec,system等函数调用系统命令
- easy php安装完成后启动出现丢失MSVCR110.dll错误
- Matplotlib Tutorial(译)