3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private static function VALUE1(){ return 'func'; } private static $VALUE2 = 'var'; private const VALUE3 = 'cost'; public static function func_value(){ return static::VALUE1(); } public static function member_value(){ return static::$VALUE2; } public static function const_value(){ return static::VALUE3; } } class B extends A { } echo A::func_value(); echo "\n"; echo B::func_value(); echo "\n---\n"; echo A::member_value(); echo "\n"; echo B::member_value(); echo "\n---\n"; echo A::const_value(); echo "\n"; echo B::const_value();
Output for 8.0.0
func func --- var var --- cost Fatal error: Uncaught Error: Undefined constant B::VALUE3 in /in/HiPuc:22 Stack trace: #0 /in/HiPuc(43): A::const_value() #1 {main} thrown in /in/HiPuc on line 22
Process exited with code 255.
Output for 7.4.0 - 7.4.13
func func --- var var --- cost Fatal error: Uncaught Error: Undefined class constant 'VALUE3' in /in/HiPuc:22 Stack trace: #0 /in/HiPuc(43): A::const_value() #1 {main} thrown in /in/HiPuc on line 22
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.24
func func --- var Fatal error: Uncaught Error: Cannot access property B::$VALUE2 in /in/HiPuc:18 Stack trace: #0 /in/HiPuc(37): A::member_value() #1 {main} thrown in /in/HiPuc on line 18
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33
Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /in/HiPuc on line 11
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_CONST, expecting T_VARIABLE in /in/HiPuc on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONST, expecting T_VARIABLE in /in/HiPuc 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/HiPuc on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/HiPuc 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/HiPuc on line 5
Process exited with code 255.