3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Palette { protected static $_valid_colours = array( 'red' => array(255,0,0), 'green' => array(0,255,0), 'blue' => array(0,0,255), 'yellow' => array(255,255,0), 'magenta' => array(255,0,255), 'cyan' => array(0,255,255), 'black' => array(0,0,0) ); protected $_selected_colours; public function __construct($selections){ foreach($selections as $selection){ if( is_array($selection) ){ if( count($selection) !== 3 ){ throw new InvalidArgumentException("Invalid RGB value"); } foreach( $selection as $value ){ if( !is_int($value) || $value < 0 || $value > 255 ){ throw new InvalidArgumentException("Invalid RGB value"); } } $this->_selected_colours[] = $selection; continue; } if( !is_string($selection) ){ throw new InvalidArgumentException("Invalid (non-string, non-array) colour"); } $selection = strtolower($selection); if( !isset(static::$_valid_colours[ $selection ]) ){ throw new InvalidArgumentException("Unknown colour [$selection]"); } $this->_selected_colours[] = static::$_valid_colours[ $selection ]; } } public function get_colours() { return $this->_selected_colours; } }
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/BhfPb on line 37
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/BhfPb on line 37
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/BhfPb 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_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/BhfPb 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/BhfPb on line 4
Process exited with code 255.