3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} $a = new A; $a->foo = "dynamic property"; $ro = new ReflectionObject($a); $prop = $ro->getProperty('foo'); try { var_dump($prop->getValue($a)); var_dump($prop->getValue(new A)); } catch (ReflectionException $ex) { echo "Caught!\n"; try { var_dump($prop->getValue(new A)); } catch (ReflectionException $ex) { var_dump($ex->getMessage()); } }

preferences:
43.56 ms | 402 KiB | 5 Q