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

发布于 分类 PHP

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.

本页面显示内容已针对移动端进行优化,点击查看完整版本