ReflectionClass::getDocComment
作用:获取文档注释
用例:
<?php
/**
* A test class
*
* @param foo bar
* @return baz
*/
class TestClass {
/**
* This class1111 will test annotations.
*
* @test
* @constTest(TestClass::ABC)
* @order('ASC', 'field1')
* @order('DESC', 'field2')
*/
function fn(){
echo "22";
}
}
$rc = new ReflectionClass('TestClass');
var_dump($rc->getDocComment())
//output:
string(55) "/**
* A test class
*
* @param foo bar
* @return baz
*/"
var_dump($rc->getMethod('fn')->getDocComment());
//output:
string(152) "/**
* This class1111 will test annotations.
*
* @test
* @constTest(TestClass::ABC)
* @order('ASC', 'field1')
* @order('DESC', 'field2')
*/"
?>
参考
http://php.net/manual/zh/reflectionclass.getdoccomment.php
本文介绍PHP中ReflectionClass类的getDocComment方法使用方法,该方法用于获取类或方法的文档注释。通过示例展示了如何从TestClass类及其fn方法中提取文档注释。

被折叠的 条评论
为什么被折叠?



