Class
Using ReflectionClass
to access the class, and thus get the comment value using method getDocComment
:
$reflection = new ReflectionClass('Usuariosontroller');
echo $reflection->getDocComment();
Example Ideone .
Method
Using ReflectionClass
to access the class, now use the getMethod
to access the method you want to obtain the information by using the getDocComment
:
$reflection = new ReflectionClass('Usuariosontroller');
echo $reflection->getMethod('getIndex')->getDocComment();
Example Ideone .
Function
Use ReflectionFunction
to access the function, in sequence the getDocComment
to access the comment:
$reflection = new ReflectionFunction('beber');
$reflection->getDocComment()
Example Ideone .
Note:
There are a few ways to make a comment, however, the above methods worked only if you use the comment whose token is T_DOC_COMMENT
, ie comments that obey the syntax: /** */
, then comments using the token T_COMMENT
- syntax // or #, and /* */
- will be ignored.