3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Colour { case Red; case Blue; case Green; public static function fromCaseName (string $name): ?self { $cases = self::cases(); foreach ($cases as $selCase) { if ($selCase->name === $name) { return $selCase; } } return null; } public function toRgb () { return match ($this) { self::Red => "255, 0, 0", self::Blue => "0, 255, 0", self::Green => "0, 0, 255" }; } public function toHex () { return match ($this) { self::Red => "#ff0000", self::Blue => "#00ff00", self::Green => "#0000ff" }; } public function toCmyk () { return match ($this) { self::Red => "0% 100% 100% 0%", self::Blue => "100% 0% 100% 0%", self::Green => "100% 100% 0% 0%" }; } } var_dump(Colour::Red); var_dump(Colour::Red->toRgb()); var_dump(Colour::Red->toHex()); var_dump(Colour::Red->toCmyk()); var_dump(Colour::fromCaseName('Red')); var_dump(Colour::fromCaseName('Red')->toRgb());
Output for git.master_jit, git.master
enum(Colour::Red) string(9) "255, 0, 0" string(7) "#ff0000" string(15) "0% 100% 100% 0%" enum(Colour::Red) string(9) "255, 0, 0"

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:
43.21 ms | 405 KiB | 5 Q