3v4l.org

run code in 300+ PHP versions simultaneously
<?php class HiddenClass { private $a = 'valueA'; // how to get it's value ? } $obj = new HiddenClass(); $reflector = new ReflectionObject($obj); $nodes = $reflector->getProperty('a'); $nodes->setAccessible(true); print_r($nodes->getValue($obj));
Output for 8.0.10
valueA

preferences:
32.09 ms | 875 KiB | 6 Q