3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { private $private = 'private'; public $public = 'public'; } $r = new \ReflectionClass('A'); $p = $r->getProperty('private'); $p->setAccessible(true); var_dump($p->getValue(new A())); $p = $r->getProperty('public'); $p->setAccessible(false); var_dump($p->getValue(new A()));
Output for 5.3.0 - 5.6.28, hhvm-3.10.0, 7.0.0 - 7.1.0
string(7) "private" string(6) "public"
Output for hhvm-3.12.0
string(7) "private" Fatal error: Uncaught TypeError: Argument 2 passed to hphp_get_property() must be an instance of string, null given in /in/O1ZOK:16 Stack trace: #0 /in/O1ZOK(16): ReflectionProperty->getValue() #1 {main}
Process exited with code 255.
Output for 5.0.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/O1ZOK on line 9 Fatal error: Call to undefined method ReflectionProperty::setAccessible() in /in/O1ZOK on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/O1ZOK on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/O1ZOK on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/O1ZOK on line 5
Process exited with code 255.