获取有关我想知道属性

问题描述:

评论,如果它是可能的(容易)在PHP工作再上一个类的属性,例如评论:获取有关我想知道属性

/** 
* A test class 
* 
* @param int $TestId primary 
* @param string $Name 
* @param int $Age 
* @param char $Gender 
* @param date $DOB 
*/ 
class Test extends DataObject { 
    /** 
    * 
    * This is what I want 
    * 
    */ 
    public $TestId = 0; 
    public $Name = ""; 
    public $Age = 0; 
    public $Gender = "M"; 
    public $DOB = ""; 
} 

我想看看我是否能得到的评论TestId属性容易吗?

+0

为什么你的类在文档块中有'@ param'? – PeeHaa 2013-05-12 22:45:21

+0

在php中寻找反射属性 – karthikr 2013-05-12 22:46:12

+0

我只是在玩弄它,看看我会得到什么,但我并不关心DocComment。 – 2013-05-12 22:46:47

ReflectionProperty::getDocComment

喜欢的东西:

$prop = new ReflectionProperty('Test', 'TestId'); 
print $prop->getDocComment(); 

有没有内置DocComment解析器,但我写了一个here如果你有兴趣。

+0

感谢您的提议,但我已经使用过您的示例,并且正在做一些稍微不同的工作。 – 2013-05-15 13:27:15