I'm looking for a way to access the default value assignment for a property without instantiating the class.
E.g.
class Foo {
private $bar = 'bar';
}
$reflClass = new ReflectionClass('Foo');
$reflProp = $reflClass-开发者_如何学JAVA>getProperty('bar');
Now what? If I use $reflProp->getValue()
(without an object argument) it will fail.
You can use getDefaultProperties()
:
var_dump($reflClass->getDefaultProperties());
精彩评论