Php从继承对象获取属性名称的最快方法

时间:2014-03-30 22:58:25

标签: php reflection properties

我有一个我的实体类扩展的泛型类。 我使用这个类来放置通用的所有内容。例如获取属性。 这是最快的方式,同时能够做到这一点 扩展类中的私有属性。

class myObj{
private strInternal;


public function getPropertyNames(){

/* Here I want function which returns all properties of the CHILD
* array_keys (get_class_vars( get_class($this) ) returns also strInternal
* which I don't want. Is ReflectionClass best alternative?
*/
}
}

class randomObj extends myObj {
protected property1;
protected property2;
protected property3;
}


test = new randomObj();
print_r ( test->getPropertyNames());

0 个答案:

没有答案
相关问题