3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; } $object = (object) ["\0Foo\0bar" => 'tab']; $r = new ReflectionProperty(Foo::class, 'bar'); $r->setAccessible(true); var_dump($r->getValue($object));
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Fatal error: Uncaught ReflectionException: Given object is not an instance of the class this property was declared in in /in/vCEFt:14 Stack trace: #0 /in/vCEFt(14): ReflectionProperty->getValue(Object(stdClass)) #1 {main} thrown in /in/vCEFt on line 14
Process exited with code 255.
Output for 7.0.20
Notice: Undefined property: stdClass::$bar in /in/vCEFt on line 14 NULL
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.6
NULL

preferences:
135.19 ms | 409 KiB | 5 Q