3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Hi, this is actually possible already in PHP already, and doesn't need any extra functionality. // You can specify a function to be called to combine multiple arguments into a single // value inside case statements like this: function f($value, $access = null) { $knownAccessTypes = [ 'read-only', 'read-write' ]; if (in_array($access, $knownAccessTypes)) { return $value.$access; } return $value; } function multiSwitchFunction($value, $access = null) { switch (f($value, $access)) { case f('a', 'read-only'): return 'a r'; case f('a', 'read-write'): return 'a w'; case f('a'): return 'a default'; case f('b', 'read-only'): return 'b r'; case f('b', 'read-write'): return 'b w '; case f('c', 'read-only'): return 'c r'; case f('c', 'read-write'): return 'c w'; case f('d', 'read-only'): return 'd r'; case f('d', 'read-write'): return 'd w' ; default: return "unknown"; } } var_dump(multiSwitchFunction('a', 'read-write')); var_dump(multiSwitchFunction('a', 'foobar')); var_dump(multiSwitchFunction('d', 'read-write')); var_dump(multiSwitchFunction('d', 'foobar'));

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.0000.01416.50
8.3.50.0080.01322.01
8.3.40.0110.00318.84
8.3.30.0140.00018.93
8.3.20.0040.00420.34
8.3.10.0040.00423.48
8.3.00.0080.00019.55
8.2.180.0190.00016.75
8.2.170.0140.00022.96
8.2.160.0070.00719.20
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00026.16
8.2.120.0040.00420.98
8.2.110.0070.00419.27
8.2.100.0040.00717.72
8.2.90.0040.00419.05
8.2.80.0080.00019.32
8.2.70.0080.00017.63
8.2.60.0000.00718.05
8.2.50.0030.00618.07
8.2.40.0030.00618.28
8.2.30.0060.00317.96
8.2.20.0080.00017.61
8.2.10.0030.00618.17
8.2.00.0050.00217.57
8.1.280.0110.00425.92
8.1.270.0040.00420.73
8.1.260.0060.00326.35
8.1.250.0050.00228.09
8.1.240.0030.00621.06
8.1.230.0090.00319.16
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0070.00317.22
8.1.190.0050.00317.53
8.1.180.0030.00618.89
8.1.170.0030.00518.56
8.1.160.0050.00220.80
8.1.150.0030.00518.77
8.1.140.0040.00417.46
8.1.130.0050.00317.76
8.1.120.0040.00417.43
8.1.110.0030.00517.45
8.1.100.0080.00017.49
8.1.90.0040.00417.46
8.1.80.0000.00717.46
8.1.70.0000.00717.46
8.1.60.0040.00417.61
8.1.50.0030.00517.45
8.1.40.0050.00317.41
8.1.30.0050.00317.55
8.1.20.0070.00317.68
8.1.10.0000.00817.57
8.1.00.0030.00717.38
8.0.300.0050.00218.77
8.0.290.0040.00417.05
8.0.280.0070.00018.42
8.0.270.0000.00817.30
8.0.260.0030.00317.27
8.0.250.0000.00716.83
8.0.240.0070.00016.99
8.0.230.0070.00016.82
8.0.220.0030.00316.92
8.0.210.0030.00316.88
8.0.200.0030.00316.97
8.0.190.0000.00716.97
8.0.180.0040.00416.98
8.0.170.0030.00516.95
8.0.160.0030.00516.82
8.0.150.0000.00716.84
8.0.140.0070.00016.89
8.0.130.0050.00013.36
8.0.120.0040.00416.89
8.0.110.0040.00416.94
8.0.100.0000.00716.95
8.0.90.0050.00316.88
8.0.80.0040.01116.97
8.0.70.0040.00416.73
8.0.60.0000.00816.93
8.0.50.0050.00216.91
8.0.30.0100.00717.10
8.0.20.0070.01417.40
8.0.10.0030.00616.89
8.0.00.0070.01016.86
7.4.330.0030.00315.13
7.4.320.0000.00816.59
7.4.300.0030.00316.54
7.4.290.0050.00316.54
7.4.280.0000.00716.61
7.4.270.0000.00716.63
7.4.260.0000.01016.63
7.4.250.0000.00716.64
7.4.240.0040.00316.52
7.4.230.0040.00416.61
7.4.220.0030.01716.55
7.4.210.0100.01016.67
7.4.200.0040.00416.54
7.4.160.0120.00316.51
7.4.150.0150.00417.40
7.4.140.0090.00917.86
7.4.130.0080.00816.62
7.4.120.0050.01116.62
7.4.110.0140.00916.61
7.4.100.0060.01616.54
7.4.90.0110.00616.49
7.4.80.0120.00919.39
7.4.70.0080.00816.42
7.4.60.0120.00816.54
7.4.50.0060.00316.68
7.4.40.0090.01316.61
7.4.30.0090.01116.47
7.4.00.0060.01014.89
7.3.330.0000.00613.32
7.3.320.0050.00313.19
7.3.310.0040.00416.25
7.3.300.0030.00316.33
7.3.290.0070.00716.29
7.3.280.0080.01016.31
7.3.270.0070.01017.40
7.3.260.0180.00316.62
7.3.250.0090.01016.50
7.3.240.0120.01216.39
7.3.230.0180.00016.51
7.3.210.0130.00316.48
7.3.200.0100.01019.39
7.3.190.0070.01316.45
7.3.180.0120.00316.50
7.3.170.0060.01016.37
7.3.160.0040.01116.43
7.3.120.0140.00714.69
7.3.110.0030.01514.88
7.3.100.0050.00914.79
7.3.90.0080.00114.89
7.3.80.0050.01014.77
7.3.70.0090.00314.72
7.3.60.0050.01014.97
7.3.50.0050.00914.88
7.3.40.0070.00714.86
7.3.30.0070.00714.55
7.3.20.0070.00516.55
7.3.10.0110.00616.51
7.3.00.0070.00716.53
7.2.330.0130.00616.68
7.2.320.0060.01016.67
7.2.310.0090.00916.68
7.2.300.0110.00616.49
7.2.290.0150.00316.77
7.2.250.0050.01515.10
7.2.240.0090.00915.25
7.2.230.0030.01315.06
7.2.220.0050.00515.02
7.2.210.0020.01114.92
7.2.200.0080.00314.97
7.2.190.0050.00915.09
7.2.180.0070.00715.14
7.2.170.0070.00614.79
7.2.130.0150.00616.32
7.2.120.0260.00316.55
7.2.110.0170.01116.29
7.2.100.0070.00716.17
7.2.90.0110.00916.37
7.2.80.0030.01316.10
7.2.70.0090.01116.77
7.2.60.0130.00716.55
7.2.50.0160.00416.53
7.2.40.0160.00916.26
7.2.30.0120.01216.38
7.2.20.0150.00316.25
7.2.10.0060.01016.40
7.2.00.0080.01017.90
7.1.330.0020.01315.61
7.1.320.0050.00715.82
7.1.310.0100.00615.68
7.1.300.0030.00915.60
7.1.290.0050.00915.86
7.1.280.0080.00715.72
7.1.270.0050.00715.60
7.1.260.0050.00615.69
7.1.250.0210.00315.42
7.1.200.0000.01415.82
7.1.100.0110.00718.17
7.1.70.0030.01217.13
7.1.60.0100.00719.34
7.1.50.0000.01716.72
7.1.00.0000.08022.43
7.0.200.0030.00716.73
7.0.140.0000.03722.22
7.0.60.0170.04320.03
7.0.50.0030.08717.88
7.0.40.0070.04320.14
7.0.30.0400.08720.23
7.0.20.0330.05020.22
7.0.10.0170.03020.18
7.0.00.0000.09320.32
5.6.280.0030.07321.16
5.6.210.0070.06720.68
5.6.200.0100.04318.29
5.6.190.0100.08020.77
5.6.180.0000.08720.46
5.6.170.0270.03320.54
5.6.160.0100.04020.44
5.6.150.0000.06018.18
5.6.140.0030.08718.19
5.6.130.0030.08318.23
5.6.120.0100.04021.02
5.6.110.0000.04720.98
5.6.100.0070.08721.05
5.6.90.0070.04721.14
5.6.80.0070.08020.38
5.5.350.0200.07720.45
5.5.340.0130.07718.07
5.5.330.0100.08020.45
5.5.320.3630.03320.30
5.5.310.0270.08020.34
5.5.300.0070.07018.01
5.5.290.0130.07318.09
5.5.280.0000.09020.98
5.5.270.0070.03720.86
5.5.260.0100.08020.88
5.5.250.0070.08720.71
5.5.240.0030.07020.29
5.4.450.0700.06319.39
5.4.440.0200.06019.50
5.4.430.0030.06019.39
5.4.420.0130.05019.52
5.4.410.0000.06319.50
5.4.400.0100.05019.12
5.4.390.0100.05319.02
5.4.380.0130.05019.11
5.4.370.0130.05019.11
5.4.360.0170.04718.97
5.4.350.0070.03713.80
5.4.340.0070.05014.02
5.4.320.0070.04714.23
5.4.310.0070.05314.27
5.4.300.0170.03314.26
5.4.290.0130.03314.35
5.4.280.0030.04314.16
5.4.270.0100.04314.15
5.4.260.0070.04314.16
5.4.250.0130.04014.11
5.4.240.0130.04314.15
5.4.230.0070.05014.32
5.4.220.0130.03314.16
5.4.210.0100.04014.18
5.4.200.0070.04314.16
5.4.190.0070.03714.17
5.4.180.0070.04314.28
5.4.170.0100.04014.11
5.4.160.0070.04314.16
5.4.150.0070.04014.28
5.4.140.0030.04713.84
5.4.130.0070.03713.81
5.4.120.0100.03713.81
5.4.110.0100.03313.78
5.4.100.0100.03313.71
5.4.90.0030.04713.85
5.4.80.0100.03713.78
5.4.70.0130.03013.71
5.4.60.0070.03713.73
5.4.50.0030.04013.85
5.4.40.0070.03313.75
5.4.30.0070.04013.76
5.4.20.0070.03713.88
5.4.10.0030.04013.70
5.4.00.0030.03713.32
5.3.290.0070.03714.62
5.3.280.0100.03714.59
5.3.270.0100.03714.66
5.3.260.0030.04314.58
5.3.250.0070.04014.74
5.3.240.0100.04014.64
5.3.230.0030.04314.59
5.3.220.0030.04314.61
5.3.210.0070.04314.61
5.3.200.0030.04314.75
5.3.190.0100.03714.70
5.3.180.0070.03714.55
5.3.170.0000.04314.62
5.3.160.0030.04014.71
5.3.150.0000.04714.55
5.3.140.0030.04014.53
5.3.130.0130.04714.70
5.3.120.0000.04714.73
5.3.110.0100.03714.60
5.3.100.0070.04014.18
5.3.90.0030.04714.05
5.3.80.0070.04014.13
5.3.70.0030.05014.00
5.3.60.0030.04314.00
5.3.50.0030.04013.88
5.3.40.0130.03314.02
5.3.30.0130.03313.91
5.3.20.0130.03713.85
5.3.10.0070.03313.70
5.3.00.0030.04013.56
5.2.170.0100.02711.10
5.2.160.0000.03311.29
5.2.150.0070.02711.18
5.2.140.0030.03711.16
5.2.130.0070.03711.25
5.2.120.0100.03711.09
5.2.110.0070.03011.24
5.2.100.0030.03011.05
5.2.90.0100.02711.22
5.2.80.0000.03711.14
5.2.70.0070.03311.24
5.2.60.0100.03311.03
5.2.50.0000.03311.00
5.2.40.0030.03310.97
5.2.30.0100.02310.91
5.2.20.0030.03710.89
5.2.10.0000.03310.88
5.2.00.0100.02710.79
5.1.60.0030.02710.01
5.1.50.0030.0279.97
5.1.40.0130.0209.91
5.1.30.0070.02310.35
5.1.20.0030.02710.30
5.1.10.0100.02310.11
5.1.00.0070.02710.01
5.0.50.0000.0338.50
5.0.40.0030.0278.45
5.0.30.0000.0338.26
5.0.20.0000.0308.17
5.0.10.0000.0238.10
5.0.00.0030.0308.23
4.4.90.0000.0205.87
4.4.80.0030.0135.90
4.4.70.0000.0175.94
4.4.60.0030.0135.85
4.4.50.0000.0175.89
4.4.40.0070.0275.81
4.4.30.0030.0205.94
4.4.20.0000.0175.99
4.4.10.0030.0205.96
4.4.00.0000.0305.89
4.3.110.0030.0135.77
4.3.100.0000.0175.75
4.3.90.0070.0175.77
4.3.80.0030.0235.74
4.3.70.0030.0135.79
4.3.60.0000.0205.80
4.3.50.0070.0135.84
4.3.40.0030.0305.82
4.3.30.0000.0234.63
4.3.20.0000.0234.60
4.3.10.0070.0174.45
4.3.00.0100.0237.19

preferences:
52.15 ms | 401 KiB | 5 Q