Skip to content

Instantly share code, notes, and snippets.

@johnpbloch
Last active December 21, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnpbloch/6349286 to your computer and use it in GitHub Desktop.
Save johnpbloch/6349286 to your computer and use it in GitHub Desktop.
<?php
class Foo {
private $bar;
public function __construct($bar){
$this->bar = $bar;
}
}
$thing = new Foo('baz');
$prop = new ReflectionProperty('Foo', 'bar');
$prop->setAccessible(true);
echo $prop->getValue($thing); // Will print 'baz'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment