ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
# Reflection Reflection用于反射管理,提供三种反射类型: * ReflectionClass:反射类 * ReflectionFile:反射文件 * ReflectionFunction:反射函数 ReflectionClass可反射一个类的相关信息,使用方式: ~~~PHP //实例化反射类 $reflectionClass = new ReflectionClass($className); /** * 获取类文件名 * @return string */ $reflectionClass->getFileName(); /** * 获取类源代码数组 * @return array|bool */ $reflectionClass->getSource(); /** * 获取反射类源代码 * @param int $start_line 源码起始行数 * @param int $end_line 源码结束行数 * @param bool $show_line 是否显示对应行号 * @return string */ $reflectionClass->getSourceCode(int $start_line = 0, int $end_line = 0, bool $show_line = false); /** * 获取反射类开始行号 * @return int */ $reflectionClass->getStartLine(); /** * 获取反射类结束行号 * @return int */ $reflectionClass->getEndLine(); ~~~ ReflectionFile可反射一个文件的相关信息,使用方式: ~~~PHP //实例化反射类 $reflectionFile = new ReflectionFile($fileName); /** * 获取反射文件的文件名 * @return string */ $reflectionFile->getFileName(); /** * 获取反射文件源码数组 * @return array|bool */ $reflectionFile->getSource(); /** * 获取反射文件源码 * @param int $start_line 源码起始行数 * @param int $end_line 源码结束行数 * @param bool $show_line 是否显示对应行号 * @return string */ $reflectionFile->getSourceCode(int $start_line = 0, int $end_line = 0, bool $show_line = false); /** * 获取反射文件开始行号 * @return int */ $reflectionFile->getStartLine(); /** * 获取反射文件结束行号 * @return int */ $reflectionFile->getEndLine(); ~~~ ReflectionFunction可反射一个函数的相关信息,使用方式: ~~~PHP //实例化反射类 $reflectionFunction = new ReflectionFunction($fileName); /** * 获取反射函数文件名 * @return string */ $reflectionFunction->getFileName(); /** * 获取反射函数源码数组 * @return array|bool */ $reflectionFunction->getSource(); /** * 获取反射函数源码 * @param int $start_line 源码起始行数 * @param int $end_line 源码结束行数 * @param bool $show_line 是否显示对应行号 * @return string */ $reflectionFunction->getSourceCode(int $start_line = 0, int $end_line = 0, bool $show_line = false); /** * 获取反射函数开始行号 * @return int */ $reflectionFunction->getStartLine(); /** * 获取反射函数结束行号 * @return int */ $reflectionFunction->getEndLine(); ~~~