网络编程 
首页 > 网络编程 > 浏览文章

php反射应用示例

(编辑:jimmy 日期: 2024/10/13 浏览:3 次 )

复制代码 代码如下:
<?php
function custom(){
}

class custom{
   public function index(){

   }
 }
print_r(get_define_position('custom'));

 /**
  * /
  * @param  string $name  函数名或者类名
  * @return array      
  */
 function get_define_position($name){
    $info = array();
    if(class_exists($name)){
      $ob = new ReflectionClass($name);
      $info['class_'.$name]= array('file'=>$ob->getFileName(),'line'=>$ob->getStartLine());
    }
    if(function_exists($name)){
      $ob = new ReflectionFunction($name);
      $info['function_'.$name]= array('file'=>$ob->getFileName(),'line'=>$ob->getStartLine());
    }
    return $info;
 }


php反射应用示例

上一篇:php异常处理使用示例
下一篇:php数组去重复数据示例
一句话新闻
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。