PHP 5.6.0beta1 released


(PHP 5 >= 5.1.0)

ReflectionClass::getDocCommentGets doc comments


public string ReflectionClass::getDocComment ( void )

Gets doc comments from a class.


Această funcție nu este documentată în prezent; este disponibilă numai lista sa de argumente.


Această funcție nu are parametri.

Valorile întoarse

The doc comment if it exists, otherwise FALSE


Example #1 ReflectionClass::getDocComment() example

* A test class
* @param  foo bar
* @return baz
class TestClass { }

$rc = new ReflectionClass('TestClass');

Exemplul de mai sus va afișa:

string(55) "/** 
* A test class
* @param  foo bar
* @return baz

Vedeți de asemenea

add a note add a note

User Contributed Notes 2 notes

joe dot scylla at gmail dot com
4 years ago
If you're using a bytecode cache like eAccelerator this method will return FALSE even if there is a properly formatted Docblock. It looks like the information required by this method gets stripped out by the bytecode cache.
uramihsayibok, gmail, com
3 years ago
According to what I can find in the PHP (5.3.2) source code, getDocComment will return the doc comment as the parser found it.
The doc comment (T_DOC_COMMENT) must begin with a /** - that's two asterisks, not one. The comment continues until the first */. A normal multi-line comment /*...*/ (T_COMMENT) does not count as a doc comment.

The doc comment itself includes those five characters, so <?php substr($doccomment, 3, -2) ?> will get you what's inside. A call to trim() after is recommended.
To Top