3v4l.org

run code in 500+ PHP versions simultaneously
<?php function mysweetcode($argument){ $required=['first'];//specify required parameters here $default=['first'=>0,'second'=>1,'third'=>2];//define all parameters with their default values here $missing=[]; if(!is_array($argument)) return false; $argument=array_intersect_key($argument,$default); foreach($required as $k=>$v){//check for missing required parameters if(!isset($argument[$v])) $missing[]=$v; } if(!empty($missing)){// if required are missing trigger or throw error according to the PHP version $cm=count($missing); if (version_compare(PHP_VERSION, '7.0.0') < 0) { trigger_error(call_user_func_array('sprintf', array_merge(array('Required '.(($cm>1)?'parameters:':'parameter:'). str_repeat('%s,',$cm).(($cm>1)?' are':' is').' missing'),$missing)), E_USER_ERROR); }else{ throw new Error(call_user_func_array('sprintf',array_merge( array('Required '.(($cm>1)?'parameters:':'parameter:'). str_repeat('%s',$cm).(($cm>1)?' are':' is').' missing'),$missing))); } } $default=array_merge($default,$argument);//assign given values to parameters extract($default);/*extract the parameters to allow further checking and other operations in the function or method*/ unset($required,$missing,$argument,$default,$k,$v);//gain some space //then you can use $first,$second,$third in your code return $first+$second+$third; } var_dump(mysweetcode(['first'=>9,'third'=>8])); var_dump(mysweetcode(['third'=>8]));

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.5.90.0070.00617.99
8.5.80.0040.00417.12
8.5.70.0070.00617.89
8.5.60.0030.00517.73
8.5.50.0080.00617.73
8.5.40.0050.00417.13
8.5.30.0090.00519.10
8.5.20.0070.00619.15
8.5.10.0080.00517.06
8.5.00.0110.00419.58
8.4.240.0090.00820.59
8.4.230.0110.00519.67
8.4.220.0090.00719.79
8.4.210.0110.00420.68
8.4.200.0080.00321.69
8.4.190.0040.00621.75
8.4.180.0110.00620.71
8.4.170.0110.00520.92
8.4.160.0110.00522.77
8.4.150.0070.00518.52
8.4.140.0080.00718.72
8.4.130.0080.00618.30
8.4.120.0070.00421.92
8.4.110.0100.00519.29
8.4.100.0070.00719.32
8.4.90.0060.00320.98
8.4.80.0080.00619.38
8.4.70.0080.00618.97
8.4.60.0060.01018.27
8.4.50.0090.00518.46
8.4.40.0070.00819.55
8.4.30.0070.00418.02
8.4.20.0100.00520.13
8.4.10.0030.00818.08
8.3.330.0110.00819.45
8.3.320.0080.00718.69
8.3.310.0080.00819.58
8.3.300.0100.00718.58
8.3.290.0120.00719.29
8.3.280.0100.00619.82
8.3.270.0070.00617.85
8.3.260.0080.00716.83
8.3.250.0080.00518.79
8.3.240.0050.00617.04
8.3.230.0100.00517.64
8.3.220.0060.00317.90
8.3.210.0080.00516.84
8.3.200.0070.00617.78
8.3.190.0070.00617.02
8.3.180.0090.00516.86
8.3.170.0090.00618.85
8.3.160.0050.00317.96
8.3.150.0080.00617.90
8.3.140.0030.00518.93
8.3.130.0070.00217.74
8.3.120.0050.00517.77
8.3.110.0050.00517.82
8.3.100.0060.00316.90
8.3.90.0060.00322.73
8.3.80.0060.00417.51
8.3.70.0050.00717.63
8.3.60.0060.01017.68
8.3.50.0110.00517.12
8.3.40.0070.00618.45
8.3.30.0060.00618.50
8.3.20.0030.00618.35
8.3.10.0060.00319.86
8.3.00.0060.00421.73
8.2.330.0070.00318.29
8.2.320.0080.00619.13
8.2.310.0090.00718.30
8.2.300.0070.00821.05
8.2.290.0080.00618.71
8.2.280.0090.00518.44
8.2.270.0080.00617.05
8.2.260.0090.00716.72
8.2.250.0030.00617.04
8.2.240.0020.00817.77
8.2.230.0080.00119.69
8.2.220.0060.00327.21
8.2.210.0070.00721.82
8.2.200.0050.00517.59
8.2.190.0080.00617.72
8.2.180.0120.00317.65
8.2.170.0090.00521.47
8.2.160.0060.00618.60
8.2.150.0050.00321.99
8.2.140.0070.00621.34
8.2.130.0050.00422.94
8.2.120.0090.00018.98
8.2.110.0040.00519.95
8.2.100.0090.00318.06
8.2.90.0040.00517.85
8.2.80.0050.00419.23
8.2.70.0080.00317.80
8.2.60.0060.00318.82
8.2.50.0030.00518.05
8.2.40.0050.00318.06
8.2.30.0060.00318.97
8.2.20.0050.00418.92
8.2.10.0040.00418.06
8.2.00.0050.00418.01
8.1.340.0060.00617.59
8.1.330.0080.00620.21
8.1.320.0070.00716.36
8.1.310.0040.00416.65
8.1.300.0070.00817.25
8.1.290.0100.00323.23
8.1.280.0130.00521.15
8.1.270.0080.00818.58
8.1.260.0090.00122.04
8.1.250.0090.00222.90
8.1.240.0090.00620.09
8.1.230.0080.00318.67
8.1.220.0060.00718.60
8.1.210.0070.00317.94
8.1.200.0050.00717.39
8.1.190.0070.00617.21
8.1.180.0060.00418.67
8.1.170.0080.00218.03
8.1.160.0050.00519.18
8.1.150.0050.00418.92
8.1.140.0060.00319.73
8.1.130.0050.00319.73
8.1.120.0050.00518.50
8.1.110.0050.00418.30
8.1.100.0060.00318.23
8.1.90.0070.00418.04
8.1.80.0010.00818.25
8.1.70.0040.00618.33
8.1.60.0070.00417.51
8.1.50.0070.00217.52
8.1.40.0050.00417.63
8.1.30.0080.00318.39
8.1.20.0060.00318.17
8.1.10.0050.00417.21
8.1.00.0100.00218.02
8.0.300.0090.00217.79
8.0.290.0060.00317.75
8.0.280.0060.00418.54
8.0.270.0050.00316.94
8.0.260.0030.00619.11
8.0.250.0030.00617.74
8.0.240.0030.00617.49
8.0.230.0070.00017.90
8.0.220.0050.00317.40
8.0.210.0040.00616.79
8.0.200.0060.00417.06
8.0.190.0080.00416.84
8.0.180.0090.00416.90
8.0.170.0110.00717.04
8.0.160.0110.00517.04
8.0.150.0130.00316.88
8.0.140.0100.00617.72
8.0.130.0140.00315.01
8.0.120.0090.00617.47
8.0.110.0070.00717.78
8.0.100.0060.00617.90
8.0.90.0020.00617.69
8.0.80.0070.00717.37
8.0.70.0030.00517.58
8.0.60.0040.00417.67
8.0.50.0040.00417.73
8.0.30.0110.00517.27
8.0.20.0100.00517.75
8.0.10.0040.00417.72
8.0.00.0090.00517.50
7.4.330.0030.00317.07
7.4.320.0040.00317.45
7.4.300.0010.00717.56
7.4.290.0020.00617.42
7.4.280.0050.00217.35
7.4.270.0050.00217.25
7.4.260.0050.00317.33
7.4.250.0020.00517.25
7.4.240.0050.00317.35
7.4.230.0070.00117.27
7.4.220.0050.00416.15
7.4.210.0050.00917.20
7.4.200.0040.00417.26
7.4.190.0050.00218.08
7.4.180.0040.00418.18
7.4.160.0080.00716.86
7.4.150.0040.00417.91
7.4.140.0070.00917.76
7.4.130.0100.00617.25
7.4.120.0100.00816.77
7.4.110.0110.00716.38
7.4.100.0030.00917.10
7.4.90.0090.00417.04
7.4.80.0050.01018.59
7.4.70.0080.00717.03
7.4.60.0090.02117.16
7.4.50.0090.00417.22
7.4.40.0080.00517.53
7.4.30.0070.00018.37
7.4.20.0030.00418.41
7.4.10.0060.00416.05
7.4.00.0050.00915.76
7.3.330.0020.00515.49
7.3.320.0020.00415.82
7.3.310.0020.00517.31
7.3.300.0060.00117.44
7.3.290.0050.00217.24
7.3.280.0050.00916.98
7.3.270.0050.00318.48
7.3.260.0080.01016.90
7.3.250.0050.00515.92
7.3.240.0080.00916.87
7.3.230.0080.00717.15
7.3.220.0030.00418.35
7.3.210.0060.00617.52
7.3.200.0120.00117.46
7.3.190.0090.00617.42
7.3.180.0090.00317.36
7.3.170.0060.00617.29
7.3.160.0060.00617.43
7.3.150.0100.00316.18
7.3.140.0030.00518.41
7.3.130.0040.00418.56
7.3.120.0070.00716.11
7.3.110.0060.00815.96
7.3.100.0060.00715.99
7.3.90.0050.00615.97
7.3.80.0030.00815.79
7.3.70.0060.00515.80
7.3.60.0080.00415.88
7.3.50.0070.00615.83
7.3.40.0060.00715.74
7.3.30.0050.00815.92
7.3.20.0050.00817.07
7.3.10.0050.00717.12
7.3.00.0090.00417.09
7.2.340.0040.00417.98
7.2.330.0080.00916.36
7.2.320.0080.01116.41
7.2.310.0070.01016.54
7.2.300.0110.00516.30
7.2.290.0100.00816.69
7.2.280.0120.00516.69
7.2.270.0180.00616.26
7.2.260.0200.00816.19
7.2.250.0150.00915.49
7.2.240.0110.01115.43
7.2.230.0100.01015.59
7.2.220.0110.00815.50
7.2.210.0080.01115.46
7.2.200.0110.00915.51
7.2.190.0090.01015.56
7.2.180.0140.00615.48
7.2.170.0100.00715.57
7.2.160.0150.00816.53
7.2.150.0160.01018.43
7.2.140.0170.00718.43
7.2.130.0120.00918.51
7.2.120.0160.01018.39
7.2.110.0160.00518.59
7.2.100.0190.00616.47
7.2.90.1780.00716.37
7.2.80.0230.00716.37
7.2.70.4360.00916.41
7.2.60.3820.00716.66
7.2.50.3430.01016.59
7.2.40.3210.00616.80
7.2.30.2960.01116.68
7.2.20.2820.00916.66
7.2.10.2790.00716.76
7.2.00.2200.00616.69
7.1.330.0050.00716.08
7.1.320.0030.00816.49
7.1.310.0050.00816.19
7.1.300.0080.00716.19
7.1.290.0050.00616.35
7.1.280.0050.00516.21
7.1.270.0060.00716.33
7.1.260.0080.00616.36
7.1.250.0060.00317.44
7.1.240.0060.00417.30
7.1.230.0070.00317.21
7.1.220.1440.00315.50
7.1.210.0820.00215.31
7.1.200.1400.00615.51
7.1.190.0390.00415.58
7.1.180.3990.00815.69
7.1.170.3330.00415.32
7.1.160.3180.00615.40
7.1.150.3190.00315.49
7.1.140.2640.00815.49
7.1.130.2700.00515.65
7.1.120.3080.00315.28
7.1.110.1350.00415.34
7.1.100.0170.00715.37
7.1.90.0080.00815.12
7.1.80.0440.00615.46
7.1.70.0240.00415.35
7.1.60.0420.00724.82
7.1.50.0200.01124.53
7.1.40.0800.00524.42
7.1.30.0220.00724.45
7.1.20.0700.00524.25
7.1.10.0200.00715.40
7.1.00.1690.00715.42
7.0.330.0070.00416.47
7.0.320.0100.00316.55
7.0.310.0100.00217.09
7.0.300.0140.00516.34
7.0.290.0140.00716.98
7.0.280.0200.00816.79
7.0.270.0150.00617.25
7.0.260.0100.00516.77
7.0.250.0080.00617.42
7.0.240.0110.00416.82
7.0.230.0070.00617.38
7.0.220.0110.00316.72
7.0.210.0080.00616.78
7.0.200.0090.00617.31
7.0.190.0030.00517.37
7.0.180.0060.00216.77
7.0.170.0050.00316.62
7.0.160.0110.00316.26
7.0.150.0090.00416.85
7.0.140.0060.00817.39
7.0.130.0060.00717.33
7.0.120.0030.00317.31
7.0.110.0050.00316.86
7.0.100.0070.00017.03
7.0.90.0040.00316.98
7.0.80.0070.00417.17
7.0.70.0050.00216.98
7.0.60.0020.00516.93
7.0.50.0040.00316.65
7.0.40.0050.00217.10
7.0.30.0050.00216.80
7.0.20.0050.00216.88
7.0.10.0030.00417.10
7.0.00.0040.00317.00
5.6.400.0050.00215.62
5.6.390.0050.00415.80
5.6.380.0040.00614.99
5.6.370.0040.00416.10
5.6.360.0030.00415.94
5.6.350.0050.00315.76
5.6.340.0050.00216.13
5.6.330.0030.00315.74
5.6.320.0050.00315.91
5.6.310.0050.00215.89
5.6.300.0060.00115.92
5.6.290.0060.00116.02
5.6.280.0040.00315.97
5.6.270.0040.00415.90
5.6.260.0040.00515.46
5.6.250.0040.00516.09
5.6.240.0060.00116.00
5.6.230.0070.00416.18
5.6.220.0100.00215.93
5.6.210.0090.00415.99
5.6.200.0200.00516.54
5.6.190.0120.00816.30
5.6.180.0150.00616.35
5.6.170.0180.00316.34
5.6.160.0170.00416.06
5.6.150.0220.00716.26
5.6.140.0170.00716.13
5.6.130.0100.01016.28
5.6.120.0210.00816.10
5.6.110.0140.00616.06
5.6.100.0190.00416.25
5.6.90.0210.00515.85
5.6.80.0230.00816.01
5.6.70.0110.00616.13
5.6.60.0190.00516.14
5.6.50.0180.01015.82
5.6.40.0160.01016.16
5.6.30.0210.00615.95
5.6.20.0190.00816.16
5.6.10.0160.00516.20
5.6.00.0150.00815.92

preferences:
49.92 ms | 2114 KiB | 5 Q