我在PHP中使用反射类,但我没有关于如何在反射实例中获取属性值的线索.有可能的?
代码:
<?php
class teste {
public $name;
public $age;
}
$t = new teste();
$t->name = 'John';
$t->age = '23';
$api = new ReflectionClass($t);
foreach($api->getProperties() as $propertie)
{
print $propertie->getName() . "\n";
}
?>
Run Code Online (Sandbox Code Playgroud)
如何在foreach循环中获取属性值?
最好的祝福,