3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class PhpClassWithPropertyDefaults { public $propertyWithoutDefault; public $propertyWithNullDefault = null; } $class = new ReflectionClass('PhpClassWithPropertyDefaults'); $defaults = $class->getDefaultProperties(); var_dump($defaults); var_dump(var_dump($class->getProperty('propertyWithoutDefault')));
Output for 5.0.4 - 5.6.28, 7.0.0 - 7.1.0
array(2) { ["propertyWithoutDefault"]=> NULL ["propertyWithNullDefault"]=> NULL } object(ReflectionProperty)#2 (2) { ["name"]=> string(22) "propertyWithoutDefault" ["class"]=> string(28) "PhpClassWithPropertyDefaults" } NULL
Output for hhvm-3.10.0 - 3.13.2
array(2) { ["propertyWithoutDefault"]=> NULL ["propertyWithNullDefault"]=> NULL } object(ReflectionProperty)#4 (4) { ["info"]=> array(9) { ["name"]=> string(22) "propertyWithoutDefault" ["default"]=> bool(true) ["defaultValue"]=> NULL ["access"]=> string(6) "public" ["accessible"]=> bool(true) ["modifiers"]=> int(256) ["class"]=> string(28) "PhpClassWithPropertyDefaults" ["doc"]=> bool(false) ["type"]=> bool(false) } ["name"]=> string(22) "propertyWithoutDefault" ["class"]=> string(28) "PhpClassWithPropertyDefaults" ["forceAccessible":"ReflectionProperty":private]=> bool(false) } NULL
Output for 5.0.0 - 5.0.3
array(2) { ["propertyWithoutDefault"]=> NULL ["propertyWithNullDefault"]=> UNKNOWN:0 } object(ReflectionProperty)#2 (2) { ["name"]=> string(22) "propertyWithoutDefault" ["class"]=> string(28) "PhpClassWithPropertyDefaults" } NULL
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/neJnU on line 4
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/neJnU on line 4
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/neJnU on line 4
Process exited with code 255.