我未能通过PHP的反射来获取动态的实例变量未能通过PHP的反射
示例代码以获得动态的实例变量:
<?php
class Foo
{
public function bar()
{
$reflect = new ReflectionClass($this);
$props = $reflect->getProperties();
var_export($props);
die;
}
}
$foo = new Foo();
$foo->a = "a";
$foo->b = "b";
$foo->bar(); // Failed to print out variable a and b
任何想法?
祝贺3k rep :) – BoltClock 2011-02-06 16:36:23
@BoltClock时间快走吧 – Peter 2017-05-17 15:05:45