Reflection is a property of a OOP that enable you to get the class name, description, functions name and their parameter etc.
See an example Below
class ABC {
public $name='Arun';
public function test1() {
return 'Testing Message';
}
public function test2() {
return 'Testing Message';
}
}
$cls = new ReflectionClass('ABC');
$methods = $cls->getMethods();
$fields = array();
foreach($methods as $method) {
//Just take everything after get as the field name
$fields[] = $method->getName();
}
print_r($fields);
No comments:
Post a Comment