PHP反射读取注释

PHP反射读取注释

<?php

/**
 * class A 类注释
 */
class A
{
    /**
     * function B 方法注释
     */
    public function B()
    {
        echo "abc";
    }
}

$re = new ReflectionClass(new A());
var_dump($re->getDocComment());
var_dump($re->getMethod('B')->getDocComment());

$ref = new ReflectionMethod('A', 'B');
var_dump($ref->getDocComment());
posted @ 2021-07-19 22:02  NwN  阅读(164)  评论(0)    收藏  举报