On Fri, 2009-04-03 at 22:37 +0200, Roman Borschel wrote: > Given the following simple classes > > class Foo { > private $foo = 'value'; > public function getFoo() { return $this->foo; } > } > class Bar extends Foo {} > > Obviously, given an instance of Bar, say $bar, $bar->getFoo() returns > 'value'. > > Now the question: How do I get at this value using reflection, given > an instance of Bar?
class Foo { private $foo = "value"; } class Bar extends Foo {} $f = new Foo; // we have to know the context, as there might be multiple foo properties $r = new ReflectionProperty("Foo", "foo"); $r->setAccessible(true); var_dump($r->getValue($f)); works for me. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php