相关疑难解决方法(0)

PHP反射类.如何获取属性的值?

我在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循环中获取属性值?

最好的祝福,

php reflection get

6
推荐指数
1
解决办法
7437
查看次数

标签 统计

get ×1

php ×1

reflection ×1