3v4l.org

run code in 300+ PHP versions simultaneously
<?php // tests testCase("Testing with null", null); testCase("Testing with false", false); testCase("Testing with true", true); testCase("Testing with class", new foreachTest()); testCase("Testing with array", ["key_1" => "val_1", "key_2" => "val_2"]); testCase("Testing with undefined"); // defining the class used in the test case class foreachTest { public $propertyOne = "propertyOneValue"; public $propertyThree = "propertyThreeValue"; private $privateProperty = "privateProperty"; } // test helper function function testCase($description){ // checking for optional argument in a way that allows to "pass in" an "undefined" value $argumentCount = func_num_args(); $inputVariable = $argumentCount > 1 ? func_get_arg(1) : 'noInputDefined' ; if ($inputVariable !== 'noInputDefined') { $undefined = $inputVariable; } try{ // echo test separator with description input echo "\n\n$description (with casting) " . str_repeat("=", 48) . ">>\n\n"; // testing foreach ((array)$undefined as $k => $v) { // potential output echo "$k => $v\n"; } echo "\n\n" . str_repeat("-", 24) . ">> (without casting)\n\n"; // testing without cast foreach ($undefined as $k => $v) { // potential output echo "$k => $v\n"; } }catch(Exception $e){ // test case error $errMessage = $e->getMessage(); echo "Error: $errMessage"; } }

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.130.0060.00318.48
8.3.120.0060.00318.96
8.3.110.0060.00320.94
8.3.100.0050.00524.06
8.3.90.0060.01326.77
8.3.80.0060.00316.63
8.3.70.0040.01116.88
8.3.60.0060.01516.75
8.3.50.0090.00921.11
8.3.40.0110.00418.89
8.3.30.0110.00418.67
8.3.20.0040.00420.04
8.3.10.0050.00323.53
8.3.00.0080.00019.68
8.2.250.0000.00917.10
8.2.240.0000.00824.09
8.2.230.0080.00022.58
8.2.220.0030.00637.54
8.2.210.0110.00726.77
8.2.200.0030.00616.75
8.2.190.0140.00716.88
8.2.180.0140.00718.54
8.2.170.0040.01122.96
8.2.160.0070.01019.03
8.2.150.0050.00325.66
8.2.140.0030.00524.66
8.2.130.0030.00626.16
8.2.120.0040.00419.23
8.2.110.0000.01121.06
8.2.100.0120.00017.84
8.2.90.0040.00417.97
8.2.80.0060.00319.06
8.2.70.0050.00517.75
8.2.60.0060.00317.63
8.2.50.0000.01019.22
8.2.40.0070.00319.47
8.2.30.0000.00717.68
8.2.20.0000.00817.66
8.2.10.0080.00018.02
8.2.00.0000.00718.04
8.1.300.0090.00917.63
8.1.290.0030.00630.84
8.1.280.0120.00325.92
8.1.270.0000.00824.66
8.1.260.0060.00326.35
8.1.250.0110.00728.09
8.1.240.0060.00319.09
8.1.230.0110.00020.73
8.1.220.0040.00417.79
8.1.210.0090.00018.88
8.1.200.0030.00617.36
8.1.190.0090.00017.10
8.1.180.0030.00618.10
8.1.170.0050.00318.43
8.1.160.0060.00318.91
8.1.150.0040.00418.67
8.1.140.0040.00417.53
8.1.130.0050.00217.43
8.1.120.0070.00017.48
8.1.110.0000.00717.39
8.1.100.0030.00317.49
8.1.90.0000.00817.47
8.1.80.0020.00517.49
8.1.70.0050.00217.49
8.1.60.0030.00617.62
8.1.50.0040.00417.46
8.1.40.0030.00517.54
8.1.30.0070.00417.55
8.1.20.0000.00817.70
8.1.10.0050.00317.55
8.1.00.0080.00017.52
8.0.300.0000.00720.27
8.0.290.0000.00716.75
8.0.280.0080.00018.35
8.0.270.0040.00416.88
8.0.260.0070.00016.89
8.0.250.0040.00417.10
8.0.240.0080.00017.05
8.0.230.0050.00317.02
8.0.220.0000.00716.99
8.0.210.0030.00516.87
8.0.200.0000.00716.95
8.0.190.0080.00017.02
8.0.180.0060.00317.02
8.0.170.0000.00817.01
8.0.160.0040.00416.87
8.0.150.0050.00216.92
8.0.140.0050.00316.86
8.0.130.0000.00713.44
8.0.120.0040.00417.00
8.0.110.0040.00417.02
8.0.100.0050.00316.97
8.0.90.0030.00516.85
8.0.80.0100.00716.95
8.0.70.0030.00516.91
8.0.60.0060.00316.98
8.0.50.0030.00616.98
8.0.30.0100.01017.35
8.0.20.0130.01317.40
8.0.10.0040.00417.21
8.0.00.0060.01416.67
7.4.330.0050.00015.09
7.4.320.0000.00616.59
7.4.300.0030.00316.48
7.4.290.0030.00316.40
7.4.280.0030.00516.66
7.4.270.0070.00016.62
7.4.260.0040.00416.50
7.4.250.0000.00716.59
7.4.240.0020.00516.52
7.4.230.0070.00016.64
7.4.220.0070.00016.55
7.4.210.0070.01116.53
7.4.200.0000.00716.54
7.4.160.0090.00616.57
7.4.150.0080.01217.40
7.4.140.0150.00417.86
7.4.130.0080.01016.40
7.4.120.0130.00916.55
7.4.110.0110.01416.69
7.4.100.0090.01516.64
7.4.90.0080.00816.71
7.4.80.0110.00619.39
7.4.70.0120.00616.64
7.4.60.0070.01016.61
7.4.50.0080.00016.64
7.4.40.0170.00016.38
7.4.30.0110.01116.53
7.4.00.0000.01414.65
7.3.330.0020.00213.30
7.3.320.0050.00213.51
7.3.310.0030.00316.34
7.3.300.0040.00416.41
7.3.290.0070.01016.38
7.3.280.0090.01016.43
7.3.270.0120.01217.40
7.3.260.0110.00916.52
7.3.250.0120.00516.42
7.3.240.0060.01216.45
7.3.230.0080.01916.47
7.3.210.0140.01016.76
7.3.200.0100.00716.55
7.3.190.0060.00916.67
7.3.180.0160.00016.46
7.3.170.0060.00916.52
7.3.160.0150.00316.37
7.3.120.0030.01014.57
7.3.110.0070.01114.78
7.3.100.0060.01015.13
7.3.90.0110.00714.89
7.3.80.0030.01414.82
7.3.70.0130.00314.99
7.3.60.0070.01014.86
7.3.50.0060.00914.63
7.3.40.0140.00314.76
7.3.30.0080.00414.84
7.3.20.0090.00316.69
7.3.10.0210.01115.82
7.3.00.0290.00815.70
7.2.330.0120.00916.66
7.2.320.0130.01016.40
7.2.310.0070.01016.69
7.2.300.0070.01016.69
7.2.290.0000.01816.88
7.2.240.0030.01515.18
7.2.230.0050.00515.19
7.2.220.0000.01014.98
7.2.210.0060.00915.05
7.2.200.0060.00915.10
7.2.190.0000.01515.00
7.2.180.0040.00714.84
7.2.170.0040.01414.76
7.2.160.0060.00915.13
7.2.150.0040.01116.68
7.2.140.0110.00716.73
7.2.130.0250.00715.97
7.2.120.0210.00715.88
7.2.110.0210.01416.06
7.2.100.0170.01016.01
7.2.90.0260.00615.90
7.2.80.0250.01016.04
7.2.70.0370.00715.89
7.2.60.0220.00616.30
7.2.50.0200.01315.98
7.2.40.0250.01115.96
7.2.30.0280.01116.06
7.2.20.0170.01416.03
7.2.10.0250.00815.95
7.2.00.0150.00917.18
7.1.330.0100.00315.80
7.1.320.0040.01116.04
7.1.310.0070.01015.91
7.1.300.0060.00915.58
7.1.290.0030.01015.85
7.1.280.0070.01015.66
7.1.270.0100.00715.69
7.1.260.0030.00715.96
7.1.250.0230.00714.72
7.1.240.0440.00613.91
7.1.230.0430.01014.05
7.1.220.0390.00314.14
7.1.210.0490.00414.00
7.1.200.0270.01014.73
7.1.190.0440.00413.89
7.1.180.0460.01114.00
7.1.170.0380.00614.04
7.1.160.0360.01213.95
7.1.150.0360.00713.81
7.1.140.0360.00713.94
7.1.130.0470.00313.80
7.1.120.0330.00814.16
7.1.110.0600.01013.77
7.1.100.0200.00516.15
7.1.90.0480.00713.90
7.1.80.0370.00014.05
7.1.70.0210.00715.52
7.1.60.0200.00816.64
7.1.50.0250.00815.53
7.1.40.0500.00413.92
7.1.30.0410.01214.13
7.1.20.0340.01014.02
7.1.10.0530.00713.85
7.1.00.0240.04018.25
7.0.330.0340.00413.40
7.0.320.0460.00813.57
7.0.310.0420.01313.27
7.0.300.0270.00713.69
7.0.290.0720.00713.70
7.0.280.0480.00013.70
7.0.270.0270.00813.69
7.0.260.0320.01113.76
7.0.250.0370.00713.45
7.0.240.0350.01313.43
7.0.230.0340.01913.83
7.0.220.0460.00013.49
7.0.210.0250.00713.49
7.0.200.0190.00615.13
7.0.190.0290.01313.74
7.0.180.0440.00813.71
7.0.170.0520.00013.44
7.0.160.0470.00713.64
7.0.150.0360.01113.36
7.0.140.0370.00313.28
7.0.130.0360.01013.68
7.0.120.0500.00013.66
7.0.110.0270.00613.51
7.0.100.0200.04116.76
7.0.90.0220.02316.76
7.0.80.0270.02316.88
7.0.70.0220.02516.65
7.0.60.0290.02316.72
7.0.50.0300.03016.95
7.0.40.0280.02316.75
7.0.30.0320.02116.92
7.0.20.0330.01816.92
7.0.10.0150.02016.81
7.0.00.0220.02116.89
5.6.380.0160.00814.06
5.6.370.0170.01113.95
5.6.360.0060.01214.25
5.6.350.0070.00714.34
5.6.340.0120.00314.54
5.6.330.0090.00914.35
5.6.320.0150.00314.25
5.6.310.0260.00314.21
5.6.300.0210.00014.59
5.6.290.0170.01314.54
5.6.280.0090.03517.66
5.6.270.0100.01314.29
5.6.260.0090.00914.47
5.6.250.0110.04617.68
5.6.240.0110.02817.51
5.6.230.0090.02817.46
5.6.220.0110.03917.50
5.6.210.0050.02617.54
5.6.200.0140.02817.58
5.6.190.0130.01817.70
5.6.180.0080.02617.80
5.6.170.0090.02417.57
5.6.160.0090.02217.65
5.6.150.0110.02317.53
5.6.140.0140.02217.67
5.6.130.0080.03017.63
5.6.120.0060.02817.70
5.6.110.0120.02017.61
5.6.100.0090.02517.62
5.6.90.0090.02317.65
5.6.80.0070.03517.32
5.6.70.0070.02717.34
5.6.60.0150.04017.36
5.6.50.0140.04717.40
5.6.40.0050.03017.37
5.6.30.0110.04217.23
5.6.20.0080.04417.31
5.6.10.0020.04817.27
5.6.00.0090.04417.33
5.5.380.0080.03215.68
5.5.370.0070.02415.96
5.5.360.0080.02415.89
5.5.350.0070.02515.75
5.5.340.0100.01516.06
5.5.330.0020.02516.05
5.5.320.0100.02315.83
5.5.310.0110.03016.13
5.5.300.0080.02815.84
5.5.290.0150.02015.93
5.5.280.0060.02415.91
5.5.270.0100.02416.07
5.5.260.0110.02315.93
5.5.250.0060.02415.89
5.5.240.0070.03315.61
5.5.230.0080.04815.56
5.5.220.0060.03115.51
5.5.210.0120.04215.68
5.5.200.0120.02615.54
5.5.190.0100.02315.47
5.5.180.0080.04015.71
5.5.170.0060.00611.04
5.5.160.0090.02715.64
5.5.150.0170.03315.76
5.5.140.0070.02515.70
5.5.130.0110.04015.75
5.5.120.0150.03815.70
5.5.110.0130.03315.68
5.5.100.0070.02315.48
5.5.90.0060.04315.61
5.5.80.0070.02915.48
5.5.70.0100.03715.52
5.5.60.0090.03915.53
5.5.50.0100.03715.61
5.5.40.0120.03815.71
5.5.30.0090.02015.65
5.5.20.0070.03715.57
5.5.10.0110.03815.45
5.5.00.0090.03915.49
5.4.450.0050.02515.20
5.4.440.0070.02115.30
5.4.430.0070.02115.44
5.4.420.0080.02215.26
5.4.410.0050.02415.29
5.4.400.0060.02414.92
5.4.390.0080.04615.02
5.4.380.0050.04715.17
5.4.370.0070.04415.01
5.4.360.0080.02515.11
5.4.350.0050.03514.87
5.4.340.0050.02715.15
5.4.330.0090.00610.96
5.4.320.0030.04814.99
5.4.310.0110.03715.15
5.4.300.0110.03814.94
5.4.290.0080.04015.10
5.4.280.0070.03715.08
5.4.270.0100.04315.13
5.4.260.0100.03814.99
5.4.250.0140.03615.01
5.4.240.0100.02814.98
5.4.230.0150.03715.17
5.4.220.0080.04214.90
5.4.210.0130.02215.05
5.4.200.0080.03215.05
5.4.190.0060.02415.01
5.4.180.0080.02514.92
5.4.170.0130.03314.95
5.4.160.0170.03615.03
5.4.150.0100.02815.10
5.4.140.0080.04113.79
5.4.130.0070.03813.82
5.4.120.0070.03113.77
5.4.110.0110.04113.58
5.4.100.0090.02713.87
5.4.90.0050.04213.63
5.4.80.0120.03513.86
5.4.70.0110.02013.71
5.4.60.0030.02213.80
5.4.50.0040.03213.79
5.4.40.0080.04413.76
5.4.30.0120.03613.79
5.4.20.0050.03013.82
5.4.10.0040.02613.66
5.4.00.0050.03013.40
5.3.290.0000.01310.20
5.3.280.0130.0109.88
5.3.270.0090.01510.11
5.3.260.0140.0079.94
5.3.250.0080.00410.22
5.3.240.0080.0089.98
5.3.230.0150.00610.10
5.3.220.0070.01010.08
5.3.210.0140.00610.11
5.3.200.0070.00210.00
5.3.190.0180.00010.06
5.3.180.0090.00410.30
5.3.170.0110.00610.21
5.3.160.0130.00310.30
5.3.150.0030.00610.19
5.3.140.0100.01010.00
5.3.130.0120.00910.06
5.3.120.0080.00410.06
5.3.110.0130.00710.26
5.3.100.0130.00310.30
5.3.90.0130.00310.39
5.3.80.0030.00610.18
5.3.70.0090.00010.02
5.3.60.0170.00310.23
5.3.50.0150.00010.13
5.3.40.0080.0049.92
5.3.30.0110.00510.02
5.3.20.0090.00610.13
5.3.10.0180.0009.95
5.3.00.0110.0009.92
5.2.170.0150.0039.13
5.2.160.0160.0009.27
5.2.150.0100.0079.34
5.2.140.0140.0038.99
5.2.130.0070.0079.21
5.2.120.0080.0008.99
5.2.110.0080.0039.21
5.2.100.0100.0009.18
5.2.90.0100.0009.02
5.2.80.0030.0079.21
5.2.70.0100.0039.17
5.2.60.0050.0099.07
5.2.50.0150.0048.99
5.2.40.0090.0009.19
5.2.30.0100.0009.14
5.2.20.0070.0039.02
5.2.10.0130.0048.99
5.2.00.0110.0048.99
5.1.60.0070.0078.99
5.1.50.0000.0078.99
5.1.40.0050.0028.99
5.1.30.0090.0058.99
5.1.20.0130.0008.99
5.1.10.0050.0038.99
5.1.00.0100.0078.99
5.0.50.0080.0058.99
5.0.40.0100.0008.99
5.0.30.0080.0008.99
5.0.20.0040.0048.99
5.0.10.0000.0058.99
5.0.00.0060.0008.99
4.4.90.0050.0028.99
4.4.80.0070.0008.99
4.4.70.0000.0068.99
4.4.60.0060.0068.99
4.4.50.0090.0038.99
4.4.40.0000.0108.99
4.4.30.0040.0048.99
4.4.20.0050.0008.99
4.4.10.0080.0038.99
4.4.00.0070.0048.99
4.3.110.0110.0008.99
4.3.100.0060.0068.99
4.3.90.0000.0058.99
4.3.80.0000.0068.99
4.3.70.0080.0028.99
4.3.60.0050.0058.99
4.3.50.0050.0058.99
4.3.40.0050.0058.99
4.3.30.0080.0058.99
4.3.20.0070.0048.99
4.3.10.0030.0038.99
4.3.00.0000.0058.99

preferences:
28.79 ms | 403 KiB | 5 Q