3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Direction { const NORTH = 2; const EAST = 4; const SOUTH = 8; const WEST = 16; const UNKNOWN = PHP_INT_MAX; static function getDirectionName($direction) { switch ($direction) { case (Direction::NORTH): return "North"; case (Direction::EAST): return "East"; case (Direction::SOUTH): return "South"; case (Direction::WEST): return "West"; case (Direction::NORTH | Direction::EAST): return "Northeast"; case (Direction::SOUTH | Direction::EAST): return "Southeast"; case (Direction::NORTH | Direction::WEST): return "Northwest"; case (Direction::SOUTH | Direction::WEST): return "Southwest"; case (Direction::UNKNOWN): return "Unknown"; default: return "No Match"; } } } var_dump(Direction::NORTH & Direction::WEST); echo Direction::getDirectionName(Direction::NORTH | Direction::WEST);
Output for 5.0.0 - 7.1.0
int(0) Northwest
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/Vbtlc 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/Vbtlc 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/Vbtlc on line 5
Process exited with code 255.