3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyEnum { private $values = [ 'A' => 1, 'B' => 2, 'C' => 3, ]; private $key = null; public function __construct($key) { if (!isset($this->values[$key])) { throw new Exception('Incorrect Enum Value'); } $this->key = $key; } public function key(): string { return $this->key; } public function val(): int { return $this->values[$this->key]; } } function foo(MyEnum $foo) { echo $foo->val().PHP_EOL; } // This works foo(new MyEnum('A')); try { // Rejected, don't allow passing the underlying value foo(1); } catch (\Throwable $e) { echo $e->getMessage().PHP_EOL; } try { // Rejected, value not part of the enum foo(new MyEnum('D')); } catch (\Throwable $e) { echo $e->getMessage().PHP_EOL; }

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.0070.00718.27
8.3.50.0060.00918.20
8.3.40.0100.00618.74
8.3.30.0070.00718.87
8.3.20.0080.00019.41
8.3.10.0040.00423.66
8.3.00.0040.00420.61
8.2.180.0150.00618.31
8.2.170.0150.00022.96
8.2.160.0030.01421.01
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0040.00426.16
8.2.120.0040.00419.83
8.2.110.0100.00019.15
8.2.100.0040.00817.84
8.2.90.0000.00817.75
8.2.80.0000.00817.97
8.2.70.0060.00317.93
8.2.60.0000.00818.28
8.2.50.0030.00618.10
8.2.40.0020.00519.47
8.2.30.0070.00019.25
8.2.20.0040.00418.17
8.2.10.0040.00417.98
8.2.00.0030.00617.67
8.1.280.0040.01125.92
8.1.270.0040.00420.68
8.1.260.0030.00526.35
8.1.250.0050.00328.09
8.1.240.0030.00622.04
8.1.230.0070.00422.11
8.1.220.0080.00017.74
8.1.210.0030.00518.77
8.1.200.0080.00017.35
8.1.190.0000.00817.13
8.1.180.0060.00318.10
8.1.170.0050.00318.61
8.1.160.0000.00718.95
8.1.150.0050.00318.86
8.1.140.0000.00722.07
8.1.130.0030.00620.15
8.1.120.0000.00717.49
8.1.110.0050.00217.44
8.1.100.0040.00417.49
8.1.90.0040.00417.46
8.1.80.0080.00317.50
8.1.70.0030.00617.54
8.1.60.0070.00317.58
8.1.50.0040.00417.54
8.1.40.0060.00317.54
8.1.30.0060.00317.62
8.1.20.0000.00717.57
8.1.10.0060.00317.51
8.1.00.0050.00317.49
8.0.300.0030.00618.77
8.0.290.0060.00616.75
8.0.280.0050.00318.32
8.0.270.0040.00417.18
8.0.260.0030.00318.45
8.0.250.0000.00716.98
8.0.240.0000.00816.96
8.0.230.0030.00317.05
8.0.220.0070.00316.88
8.0.210.0040.00416.97
8.0.200.0000.00717.02
8.0.190.0000.00817.03
8.0.180.0000.00717.04
8.0.170.0040.00416.94
8.0.160.0070.00016.95
8.0.150.0030.00516.89
8.0.140.0000.00716.81
8.0.130.0000.00513.47
8.0.120.0000.00816.95
8.0.110.0040.00417.03
8.0.100.0030.00517.02
8.0.90.0080.00016.86
8.0.80.0060.01116.89
8.0.70.0050.00316.98
8.0.60.0040.00416.80
8.0.50.0000.00716.93
8.0.30.0060.01317.05
8.0.20.0130.00617.40
8.0.10.0040.00416.98
8.0.00.0090.01016.55
7.4.330.0000.00515.55
7.4.320.0000.00616.50
7.4.300.0030.00316.52
7.4.290.0000.00716.49
7.4.280.0050.00416.52
7.4.270.0000.00716.64
7.4.260.0000.00716.59
7.4.250.0070.00016.51
7.4.240.0000.00816.50
7.4.230.0000.00716.30
7.4.220.0040.00416.50
7.4.210.0060.00916.56
7.4.200.0030.00316.61
7.4.160.0090.00616.50
7.4.140.0100.01017.86
7.4.130.0130.01016.50
7.4.120.0120.00716.57
7.4.110.0120.00616.45
7.4.100.0080.00816.59
7.4.90.0130.01016.62
7.4.80.0160.00619.39
7.4.70.0090.01216.72
7.4.60.0130.00316.43
7.4.50.0110.00416.34
7.4.40.0100.00716.53
7.4.00.0040.00914.92
7.3.330.0030.00313.46
7.3.320.0000.00613.30
7.3.310.0090.00016.30
7.3.300.0000.00716.31
7.3.290.0070.00016.30
7.3.280.0110.00616.41
7.3.260.0100.00816.45
7.3.240.0110.00816.42
7.3.230.0070.01016.55
7.3.210.0060.01616.41
7.3.200.0000.01516.51
7.3.190.0120.00916.40
7.3.180.0100.01016.40
7.3.170.0140.00716.63
7.3.160.0130.00316.62
7.3.120.0040.01114.65
7.3.110.0040.01214.88
7.3.100.0080.00814.91
7.3.90.0090.00914.86
7.3.80.0000.01214.88
7.3.70.0080.00014.68
7.3.60.0100.00714.93
7.3.50.0070.01014.83
7.3.40.0070.00414.88
7.3.30.0060.00614.82
7.3.20.0030.00616.68
7.3.10.0070.00716.84
7.3.00.0090.00616.51
7.2.330.0090.00916.68
7.2.320.0120.00916.74
7.2.310.0030.01416.81
7.2.300.0090.01516.68
7.2.290.0100.00616.61
7.2.250.0100.01014.72
7.2.240.0030.01614.95
7.2.230.0100.00614.84
7.2.220.0070.01014.86
7.2.210.0090.00614.80
7.2.200.0080.00015.14
7.2.190.0120.00315.02
7.2.180.0080.00415.09
7.2.170.0130.00014.83
7.2.110.0820.01014.80
7.2.100.0760.00714.30
7.2.90.0620.01314.78
7.2.80.0660.01014.64
7.2.70.0990.01014.80
7.2.60.1130.00615.01
7.2.50.0750.00615.05
7.2.40.1080.00314.86
7.2.30.1140.00014.98
7.2.20.1100.00714.45
7.2.10.0740.00715.07
7.2.00.0740.00715.07
7.1.330.0040.01115.51
7.1.320.0040.00815.46
7.1.310.0050.00315.74
7.1.300.0130.00315.96
7.1.290.0000.01015.56
7.1.280.0030.00615.90
7.1.270.0080.00815.71
7.1.260.0060.01015.92
7.1.230.0940.00613.28
7.1.220.0650.01013.60
7.1.210.0750.00613.55
7.1.200.0610.00913.81
7.1.190.0700.00313.70
7.1.180.0630.00713.88
7.1.170.1150.00614.01
7.1.160.0800.00614.16
7.1.150.0760.00313.77
7.1.140.1070.00713.43
7.1.130.0710.01313.86
7.1.120.0860.00413.73
7.1.110.1080.01013.85
7.1.100.0760.00613.96
7.1.90.0600.00713.81
7.1.80.0670.00713.70
7.1.70.0900.01013.64
7.1.60.1120.01431.96
7.1.50.1110.00731.84
7.1.40.0720.01431.52
7.1.30.1510.01331.98
7.1.20.1530.00331.89
7.1.10.1030.00614.02
7.1.00.0810.01014.28
5.6.380.0110.00413.92

preferences:
54.55 ms | 400 KiB | 5 Q