Class
Using the ReflectionClass
to access the class, and thus get the value of the comment using the method getDocComment
:
$reflection = new ReflectionClass('Usuariosontroller');
echo $reflection->getDocComment();
Example Ideone.
Method
Also using the ReflectionClass
to access the class, now use the getMethod
to access the method you want to obtain the information using the method getDocComment
:
$reflection = new ReflectionClass('Usuariosontroller');
echo $reflection->getMethod('getIndex')->getDocComment();
Example Ideone.
Function
Use the ReflectionFunction
to access the function, in sequence the getDocComment
to access the comment:
$reflection = new ReflectionFunction('beber');
$reflection->getDocComment()
Example Ideone.
Observing:
There are a few ways to comment, but the above methods only work if you use the comment whose token is T_DOC_COMMENT
, that is, comments that obey syntax: /** */
, then comments using token T_COMMENT
- syntax // or #, and /* */
- will be ignored.
Reflectionclass
– Homer Simpson
@Homersimpson responds there to win votes, man
– Wallace Maxters