3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public static $staticProperty = 'foobar'; public $property = 'barfoo'; private $privateProperty = 'foofoo'; } $reflectionClass = new ReflectionClass('Foo'); var_dump($reflectionClass->getProperty('staticProperty')->getValue()); var_dump($reflectionClass->getProperty('property')->getValue(new Foo)); $reflectionProperty = $reflectionClass->getProperty('privateProperty'); $reflectionProperty->setAccessible(true); var_dump($reflectionProperty->getValue());

preferences:
53.33 ms | 402 KiB | 5 Q