Home  >  Article  >  Backend Development  >  php怎么判断成员函数的访问权限是public

php怎么判断成员函数的访问权限是public

WBOY
WBOYOriginal
2016-06-13 13:28:07866browse

php如何判断成员函数的访问权限是public
class test{
  public function aaa(){
  echo 'aaat';
  }

  protected function bbb(){
  echo 'bbb';
  }

  private function ccc(){
  echo 'ccc';
  }
}

如何判断 test 这个类 aaa,bbb,ccc 成员函数 是属于 public或protected或private 的访问权限。
请给为大侠解答。
分送上。

------解决方案--------------------
stackoverflow上面找到的方法

PHP code
getModifiers());
print_r($s);

$foo = new ReflectionMethod('Test', 'bar');
$s=Reflection::getModifierNames($foo->getModifiers());
print_r($s);

------解决方案--------------------
http://cn.php.net/manual/en/class.reflectionmethod.php
------解决方案--------------------
反射的典型应用
------解决方案--------------------
http://www.php.net/manual/en/reflectionmethod.construct.php

一看就是反射,翻了翻就找到了这个。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn