3v4l.org

run code in 200+ PHP versions simultaneously
<?php class c1 { const ZERO = 0; const ONE = 1; public static $a1 = array(self::ONE => 'one'); public static $a2 = array(self::ZERO => 'zero'); } $v1 = c1::$a1; $v2 = c1::$a2; $v1[] = 1; $v2[] = 1; var_dump($v1); var_dump($v2);
based on VY1bq
Output for 5.1.0 - 5.4.32, 5.5.0 - 5.5.16, 5.5.23 - 7.3.1
array(2) { [1]=> string(3) "one" [2]=> int(1) } array(2) { [0]=> string(4) "zero" [1]=> int(1) }
Output for 5.4.34 - 5.4.45, 5.5.18 - 5.5.22
Warning: Cannot add element to the array as the next element is already occupied in /in/m4eiS on line 15 array(2) { [1]=> string(3) "one" [0]=> int(1) } array(1) { [0]=> string(4) "zero" }
Output for 5.0.0 - 5.0.5
Fatal error: Cannot access self:: when no class scope is active in /in/m4eiS on line 11
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/m4eiS 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_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/m4eiS 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/m4eiS on line 5
Process exited with code 255.