/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018\10\12 0012
 * Time: 14:30
 */

/**
 * class Dog 类注解
 */
class Dog{
    /**
     * class function say 方法注解
     */
    public function say()
    {
        echo "wang !";
    }

}

$re  = new ReflectionClass(new Dog());
var_dump($re->getDocComment());
var_dump($re->getMethod('say')->getDocComment());

 

注意的是注解格式 必须是 /** 开头的

 请参考 :   https://www.phpdoc.org/

 

/* 和//  等注释型的都获取失败.

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
猜你喜欢
  • 2021-10-26
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
相关资源
相似解决方案