3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
45.82 ms | 401 KiB | 8 Q