PHP 从映象(Reflection)类中读取属性信息

来源:互联网 发布:nba2k18科比捏脸数据 编辑:程序博客网 时间:2024/06/05 15:16

 

<?php
/**
    从映象(Reflection)类中读取属性信息
    用该方法可以查看指定类中的方法和属性    
*/
include_once 'mycal.php';//一个类文件或采用系统中的类如Exception
$obj = new ReflectionClass('myCal');
//$obj = new ReflectionClass(Exception);
$arr = $obj->getMethods();//取得类中所有的名字
//$arr = $obj->getMethod('Calendar');//取得指定类的名字
//$arr = ReflectionClass::getMethod('myCal');

print_r($arr);
//Reflection::export(new ReflectionClass('ReflectionClass'));//通过此方法可以看到ReflectionClass中所有的属性和方法
?>
原创粉丝点击