3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Enum { private $name; protected $allow = []; private static $enums; private function __construct($name) { if (!in_array($name, $this->allow, true)) { throw new \TypeError('Undefined enum ' . get_class($this) . '::' . $name . '()'); } $this->name = $name; } public static function __callStatic($name, $args) { $id = static::class . ".$name"; if (!isset(self::$enums[$id])) { $enum = new static($name); self::$enums[$id] = $name; } return self::$enums[$id]; } public function __toString() { $this->name; } } /** * @method static RED() * @method static GREEN() * @method static BLUE() */ class Color extends Enum { protected $allow = ['RED', 'GREEN', 'BLUE']; } $red = Color::RED(); $red2 = Color::RED(); $green = Color::GREEN(); var_dump($red === $red2); var_dump($red == $red2); var_dump($red === $green); var_dump($red == $green); var_dump((string) $red); var_dump((string) $green); $geern = Color::GEERN(); // Intentional typo. Throws.

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0060.00916.63
8.3.50.0110.00718.05
8.3.40.0070.01418.79
8.3.30.0090.00618.79
8.3.20.0040.00421.73
8.3.10.0040.00421.79
8.3.00.0040.00419.57
8.2.180.0070.01418.29
8.2.170.0150.00018.99
8.2.160.0070.00722.96
8.2.150.0000.00825.66
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0080.00021.07
8.2.110.0090.00022.25
8.2.100.0050.01018.01
8.2.90.0040.00419.14
8.2.80.0040.00418.03
8.2.70.0050.00517.75
8.2.60.0030.00617.93
8.2.50.0000.00818.10
8.2.40.0000.00820.23
8.2.30.0030.00519.31
8.2.20.0040.00418.16
8.2.10.0050.00218.09
8.2.00.0050.00218.06
8.1.280.0070.01425.92
8.1.270.0090.00324.66
8.1.260.0030.00626.35
8.1.250.0000.00728.09
8.1.240.0030.00623.96
8.1.230.0040.00817.76
8.1.220.0040.00417.76
8.1.210.0000.00818.77
8.1.200.0060.00317.23
8.1.190.0000.00817.23
8.1.180.0090.00018.10
8.1.170.0050.00318.61
8.1.160.0040.00418.80
8.1.150.0000.00718.89
8.1.140.0040.00419.59
8.1.130.0030.00318.93
8.1.120.0040.00417.46
8.1.110.0030.00617.40
8.1.100.0050.00317.38
8.1.90.0020.00517.54
8.1.80.0000.00717.49
8.1.70.0000.00717.48
8.1.60.0020.00517.59
8.1.50.0030.00617.64
8.1.40.0050.00317.47
8.1.30.0000.00817.66
8.1.20.0000.00717.51
8.1.10.0000.00717.61
8.1.00.0050.00317.55
8.0.300.0020.00518.77
8.0.290.0000.00816.75
8.0.280.0030.00318.42
8.0.270.0000.00817.28
8.0.260.0000.00617.30
8.0.250.0040.00417.04
8.0.240.0050.00217.08
8.0.230.0040.00416.90
8.0.220.0000.00716.87
8.0.210.0030.00516.95
8.0.200.0040.00417.02
8.0.190.0080.00017.04
8.0.180.0040.00417.01
8.0.170.0000.00816.93
8.0.160.0040.00416.98
8.0.150.0000.00716.92
8.0.140.0000.00716.93
8.0.130.0030.00313.44
8.0.120.0000.00816.95
8.0.110.0040.00417.04
8.0.100.0020.00516.85
8.0.90.0030.00517.03
8.0.80.0150.00016.98
8.0.70.0040.00416.87
8.0.60.0000.00816.94
8.0.50.0040.00416.94
8.0.30.0110.00617.17
8.0.20.0080.01017.40
8.0.10.0040.00417.16
8.0.00.0090.00916.79
7.4.330.0060.00015.55
7.4.320.0060.00016.40
7.4.300.0040.00416.61
7.4.290.0040.00416.48
7.4.280.0000.00716.43
7.4.270.0030.00316.39
7.4.260.0030.00316.50
7.4.250.0070.00016.50
7.4.240.0030.00316.64
7.4.230.0070.00016.53
7.4.220.0030.00516.42
7.4.210.0080.00816.56
7.4.200.0050.00316.52
7.4.160.0090.00916.55
7.4.150.0090.00917.40
7.4.140.0130.01117.86
7.4.130.0070.01016.63
7.4.120.0080.01416.56
7.4.110.0080.00816.55
7.4.100.0080.00816.72
7.4.90.0180.00316.76
7.4.80.0100.01019.39
7.4.70.0090.00916.44
7.4.60.0110.00416.59
7.4.50.0070.00716.48
7.4.40.0080.00916.27
7.4.30.0070.01016.40
7.4.00.0090.00314.91
7.3.330.0000.00613.47
7.3.320.0000.00513.44
7.3.310.0030.00316.32
7.3.300.0000.00716.47
7.3.290.0090.01016.41
7.3.280.0070.00716.39
7.3.270.0110.00717.40
7.3.260.0100.01016.60
7.3.250.0120.00716.58
7.3.240.0080.00916.54
7.3.230.0160.00616.48
7.3.210.0070.01016.66
7.3.200.0090.00816.46
7.3.190.0110.00616.52
7.3.180.0140.00416.54
7.3.170.0130.01016.64
7.3.160.0110.00416.70
7.2.330.0180.00016.58
7.2.320.0130.00316.46
7.2.310.0060.01316.43
7.2.300.0090.00916.73
7.2.290.0110.00516.61
7.2.80.0060.01016.92
7.2.60.0110.00417.00
7.2.00.0000.01319.66
7.1.200.0040.00715.72
7.1.70.0070.00417.22
7.1.60.0090.00617.32
7.1.50.0030.01017.00
7.1.40.0000.01116.77
7.1.30.0070.00716.68
7.1.20.0000.01116.77
7.1.10.0050.00516.53
7.1.00.0030.00616.84
7.0.200.0000.01016.61
7.0.190.0050.00316.61
7.0.180.0060.00216.37
7.0.170.0060.00316.37
7.0.160.0040.00716.46
7.0.150.0000.00916.34
7.0.140.0000.00716.36
7.0.130.0050.00316.48
7.0.120.0040.00416.59
7.0.110.0040.00416.40
7.0.100.0040.00416.29
7.0.90.0080.00416.39
7.0.80.0050.00516.27
7.0.70.0050.00316.37
7.0.60.0030.00716.19
7.0.50.0080.00016.39
7.0.40.0030.00614.78
7.0.30.0040.00714.78
7.0.20.0030.00714.78
7.0.10.0000.00714.78
7.0.00.0000.00714.78

preferences:
58.72 ms | 400 KiB | 5 Q