3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar = 'baz'; private function taz() { return 'waz'; } } var_dump((new ReflectionProperty(Foo::class, 'bar'))->getValue(new Foo)); var_dump((new ReflectionMethod(Foo::class, 'taz'))->invoke(new Foo));
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
string(3) "baz" string(3) "waz"
Output for 8.0.1 - 8.0.30
Fatal error: Uncaught ReflectionException: Cannot access non-public property Foo::$bar in /in/PNeeZ:8 Stack trace: #0 /in/PNeeZ(8): ReflectionProperty->getValue(Object(Foo)) #1 {main} thrown in /in/PNeeZ on line 8
Process exited with code 255.

preferences:
128.75 ms | 401 KiB | 90 Q