<?php
class MyClass
{
private $foo = 'bar';
}
$property = new ReflectionProperty("MyClass", "foo");
$property->setAccessible(true);
$obj = new MyClass();
echo $property->getValue($obj);
echo $obj->foo;
?>
bar
Fatal error: Uncaught Error: Cannot access private property MyClass::$foo in /in/WJqTv:12