Bugs & Features
@ 2012-11-28 12:15:06
<?php function enum() { for($enums = func_get_args(), $enum = reset($enums), $i = 1; $enum; $enum = next($enums), ++$i) { eval('const ' . $enum . ' = ' . $i . ';'); } } // enum() enum('CONST0', 'CONST1', 'CONST2'); print_r(CONST0);
Output for 5.3.0 - 5.6.8, php7@20140507 - 20150501, hhvm-3.6.0 - 3.7.0
1
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_CONST in /in/EC0gF(6) : eval()'d code on line 1 Parse error: syntax error, unexpected T_CONST in /in/EC0gF(6) : eval()'d code on line 1 Parse error: syntax error, unexpected T_CONST in /in/EC0gF(6) : eval()'d code on line 1 Notice: Use of undefined constant CONST0 - assumed 'CONST0' in /in/EC0gF on line 13 CONST0
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONST in /in/EC0gF(6) : eval()'d code on line 1 Parse error: parse error, unexpected T_CONST in /in/EC0gF(6) : eval()'d code on line 1 Parse error: parse error, unexpected T_CONST in /in/EC0gF(6) : eval()'d code on line 1 Notice: Use of undefined constant CONST0 - assumed 'CONST0' in /in/EC0gF on line 13 CONST0
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/EC0gF(6) : eval()'d code on line 1 Parse error: parse error in /in/EC0gF(6) : eval()'d code on line 1 Parse error: parse error in /in/EC0gF(6) : eval()'d code on line 1 Notice: Use of undefined constant CONST0 - assumed 'CONST0' in /in/EC0gF on line 13 CONST0
Process exited with code 255.