3v4l.org

run code in 500+ 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.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
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:
83.95 ms | 1107 KiB | 4 Q