忽略继承类,获取指定类中的所有方法。

NOCO发布于 分类 PHP

23天前 有1个用户阅读过

function file_get_class_methods ($file)
{
  $arr = file($file);
  foreach ($arr as $line)
  {
    if (ereg ('function ([_A-Za-z0-9]+)', $line, $regs))
      $arr_methods[] = $regs[1];
  }
  return $arr_methods;
}

function get_this_class_methods($class){
  $array1 = get_class_methods($class);
  if($parent_class = get_parent_class($class)){
    $array2 = get_class_methods($parent_class);
    $array3 = array_diff($array1, $array2);
  }else{
    $array3 = $array1;
  }
  return($array3);
} 
用get_class_methods会获取当前类和集成类的方法名,用这个函数就可以只获取指定类中的所有方法。

-- The End --

本文标题: 忽略继承类,获取指定类中的所有方法。

本文地址: https://seonoco.com/blog/ignores-all-the-methods-in-the-specified-class.

本文是否有所帮助?
点赞 0
感谢支持
0
多谢反馈
评论 0
打赏

支持微信/支付宝

评论

网友