【发布时间】:2011-02-14 17:39:57
【问题描述】:
我在 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";
}
?>
如何在 foreach 循环中获取属性值?
最好的问候,
【问题讨论】:
标签: php reflection get