3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class EnumShit { const SHOW_TEST = 1; // 2 ^ 0 const SHOW_DERP = 2; // 2 ^ 1 const SHOW_FOO = 4; // 2 ^ 2 public function __construct($type) { switch ($type) { case self::SHOW_DERP: echo "Showing derp!\n"; break; case self::SHOW_TEST: echo "Showing Test!\n"; break; case self::SHOW_FOO: echo "Showing Test!\n"; break; case self::SHOW_DERP | self::SHOW_TEST: echo "Showing both DERP and TEST!\n"; break; case self::SHOW_FOO | self::SHOW_TEST: echo "Showing both FOO and TEST!\n"; break; case self::SHOW_DERP | self::SHOW_FOO: echo "Showing both DERP and FOO!\n"; break; case self::SHOW_DERP | self::SHOW_TEST | self::SHOW_FOO: echo "Showing ALL!\n"; break; } } } new EnumShit(EnumShit::SHOW_TEST | EnumShit::SHOW_FOO);
Output for 5.0.0 - 7.1.0
Showing both FOO and TEST!
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/ILEnn 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_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/ILEnn 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/ILEnn on line 4
Process exited with code 255.