3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class MyClass { private $myProperty = true; } $class = new ReflectionClass("MyClass"); $property = $class->getProperty("myProperty"); $property->setAccessible(false); $obj = new MyClass(); echo $property->getValue($obj); // Works //echo $obj->myProperty; // Doesn't work (error)
based on utmNI
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught ReflectionException: Cannot access non-public member MyClass::myProperty in /in/G3PEb:12 Stack trace: #0 /in/G3PEb(12): ReflectionProperty->getValue(Object(MyClass)) #1 {main} thrown in /in/G3PEb on line 12
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Fatal error: Uncaught exception 'ReflectionException' with message 'Cannot access non-public member MyClass::myProperty' in /in/G3PEb:12 Stack trace: #0 /in/G3PEb(12): ReflectionProperty->getValue(Object(MyClass)) #1 {main} thrown in /in/G3PEb on line 12
Process exited with code 255.