3v4l.org

run code in 300+ 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.10.0110.00617.05
8.5.00.0170.00520.45
8.4.160.0130.00923.75
8.4.150.0020.00014.05
8.4.140.0140.00717.77
8.4.130.0090.00918.64
8.4.120.0070.00524.05
8.4.110.0130.00718.73
8.4.100.0120.00818.84
8.4.90.0050.00522.14
8.4.80.0120.00618.93
8.4.70.0090.00918.11
8.4.60.0070.01418.42
8.4.50.0130.00618.84
8.4.40.0080.01119.43
8.4.30.0080.00018.08
8.4.20.0130.00720.43
8.4.10.0000.01018.16
8.3.280.0120.00920.80
8.3.270.0080.00716.98
8.3.260.0100.01016.81
8.3.250.0080.00718.94
8.3.240.0040.00717.20
8.3.230.0120.00816.54
8.3.220.0050.00319.00
8.3.210.0110.00716.86
8.3.200.0080.00718.67
8.3.190.0100.00917.14
8.3.180.0100.00916.83
8.3.170.0100.01020.89
8.3.160.0040.00417.15
8.3.150.0090.00918.84
8.3.140.0000.00819.08
8.3.130.0080.00018.50
8.3.120.0040.00718.81
8.3.110.0030.00618.73
8.3.100.0060.00316.77
8.3.90.0080.00026.77
8.3.80.0060.00317.97
8.3.70.0060.00916.56
8.3.60.0070.01518.43
8.3.50.0140.00517.22
8.3.40.0060.00918.79
8.3.30.0080.00819.02
8.3.20.0040.00418.66
8.3.10.0040.00421.78
8.3.00.0070.00323.63
8.2.290.0100.00820.51
8.2.280.0130.00618.29
8.2.270.0110.00717.23
8.2.260.0120.00916.72
8.2.250.0030.00617.17
8.2.240.0000.00918.89
8.2.230.0100.00020.94
8.2.220.0040.00437.54
8.2.210.0070.01126.77
8.2.200.0040.00418.41
8.2.190.0100.00718.68
8.2.180.0170.00318.42
8.2.170.0120.00622.96
8.2.160.0070.00719.16
8.2.150.0040.00424.18
8.2.140.0090.00624.66
8.2.130.0050.00326.16
8.2.120.0080.00019.95
8.2.110.0030.00622.11
8.2.100.0100.00418.03
8.2.90.0000.00817.75
8.2.80.0030.00518.86
8.2.70.0070.00317.63
8.2.60.0040.00417.93
8.2.50.0000.00818.07
8.2.40.0040.00418.16
8.2.30.0060.00318.21
8.2.20.0040.00418.22
8.2.10.0040.00418.20
8.2.00.0030.00518.04
8.1.330.0130.00622.31
8.1.320.0080.01116.31
8.1.310.0040.00416.87
8.1.300.0060.01218.45
8.1.290.0060.00330.84
8.1.280.0140.00725.92
8.1.270.0000.00820.09
8.1.260.0070.00026.35
8.1.250.0090.00028.09
8.1.240.0060.00320.60
8.1.230.0070.00417.77
8.1.220.0000.00817.78
8.1.210.0040.00418.77
8.1.200.0000.01017.48
8.1.190.0000.01017.35
8.1.180.0040.00418.10
8.1.170.0060.00318.44
8.1.160.0030.00518.99
8.1.150.0040.00418.88
8.1.140.0030.00520.73
8.1.130.0030.00320.30
8.1.120.0040.00417.51
8.1.110.0050.00217.38
8.1.100.0040.00417.46
8.1.90.0060.00317.44
8.1.80.0000.00717.48
8.1.70.0000.00817.39
8.1.60.0030.00617.67
8.1.50.0040.00417.54
8.1.40.0030.00517.54
8.1.30.0100.00017.66
8.1.20.0040.00417.53
8.1.10.0040.00417.54
8.1.00.0090.00017.52
8.0.300.0050.00218.77
8.0.290.0050.00316.88
8.0.280.0030.00318.35
8.0.270.0030.00417.21
8.0.260.0000.00621.89
8.0.250.0000.00816.95
8.0.240.0000.00717.07
8.0.230.0070.00017.06
8.0.220.0070.00016.94
8.0.210.0000.00716.94
8.0.200.0030.00317.03
8.0.190.0050.00317.03
8.0.180.0040.00416.98
8.0.170.0040.00416.91
8.0.160.0040.00417.04
8.0.150.0070.00016.82
8.0.140.0040.00416.87
8.0.130.0060.00013.42
8.0.120.0040.00416.96
8.0.110.0040.00416.91
8.0.100.0030.00516.86
8.0.90.0000.00816.99
8.0.80.0080.00816.98
8.0.70.0000.00716.89
8.0.60.0040.00417.10
8.0.50.0030.00516.85
8.0.30.0130.00517.03
8.0.20.0120.00617.40
8.0.10.0050.00217.14
8.0.00.0120.00616.82
7.4.330.0000.00515.55
7.4.320.0030.00316.52
7.4.300.0000.00816.55
7.4.290.0000.00816.54
7.4.280.0040.00416.56
7.4.270.0030.00316.64
7.4.260.0050.00316.64
7.4.250.0000.00716.48
7.4.240.0030.00316.53
7.4.230.0080.00016.55
7.4.220.0050.00216.51
7.4.210.0050.01216.54
7.4.200.0030.00316.68
7.4.160.0080.00916.61
7.4.140.0070.01117.86
7.4.130.0170.00716.61
7.4.120.0110.00916.56
7.4.110.0140.01016.57
7.4.100.0000.01616.42
7.4.90.0120.00616.46
7.4.80.0050.01719.39
7.4.70.0090.01316.35
7.4.60.0140.03916.57
7.4.50.0120.00616.61
7.4.40.0110.00716.71
7.4.00.0050.01214.87
7.3.330.0000.00613.24
7.3.320.0000.00613.21
7.3.310.0000.00716.20
7.3.300.0070.00016.40
7.3.290.0040.00416.25
7.3.280.0050.01316.33
7.3.260.0100.01116.52
7.3.240.0080.01116.49
7.3.230.0130.01116.41
7.3.210.0070.01016.56
7.3.200.0190.00016.50
7.3.190.0130.01016.41
7.3.180.0120.00616.31
7.3.170.0060.01016.43
7.3.160.0070.01016.40
7.3.120.0090.00814.97
7.3.110.0070.01114.82
7.3.100.0050.01115.03
7.3.90.0060.00714.83
7.3.80.0040.01014.72
7.3.70.0070.00614.85
7.3.60.0100.00514.78
7.3.50.0080.00814.90
7.3.40.0060.00914.73
7.3.30.0040.01114.84
7.3.20.0050.01016.44
7.3.10.0050.01016.65
7.3.00.0100.00516.76
7.2.330.0060.01316.71
7.2.320.0060.01516.45
7.2.310.0030.01416.71
7.2.300.0100.00716.48
7.2.290.0100.01216.75
7.2.250.0110.00915.20
7.2.240.0080.01214.98
7.2.230.0050.01115.17
7.2.220.0080.00715.06
7.2.210.0040.01214.95
7.2.200.0090.00915.09
7.2.190.0060.00915.01
7.2.180.0080.00515.09
7.2.170.0060.00615.16
7.2.100.0230.00314.57
7.2.90.3300.00714.66
7.2.80.0280.00714.53
7.2.70.8500.01014.93
7.2.60.7480.00714.91
7.2.50.6750.00915.12
7.2.40.6360.00714.96
7.2.30.5760.01315.13
7.2.20.5530.00714.73
7.2.10.5450.00614.82
7.2.00.4280.00714.83
7.1.330.0040.00915.54
7.1.320.0020.01015.93
7.1.310.0060.00915.79
7.1.300.0080.00915.80
7.1.290.0060.00715.81
7.1.280.0040.00715.86
7.1.270.0050.01015.90
7.1.260.0100.00715.88
7.1.220.2810.00313.72
7.1.210.1560.00013.77
7.1.200.2750.00713.94
7.1.190.0700.00613.86
7.1.180.7930.01313.96
7.1.170.6590.00613.68
7.1.160.6300.01013.86
7.1.150.6320.00313.90
7.1.140.5210.01313.79
7.1.130.5340.00713.91
7.1.120.6090.00313.74
7.1.110.2660.00313.71
7.1.100.0280.00913.77
7.1.90.0110.01113.45
7.1.80.0820.01013.70
7.1.70.0430.00613.59
7.1.60.0800.01031.95
7.1.50.0340.02031.50
7.1.40.1550.00731.95
7.1.30.0390.01231.71
7.1.20.1360.00331.75
7.1.10.0360.01113.53
7.1.00.3340.01013.82
5.6.380.0030.00914.30

preferences:
166.91 ms | 403 KiB | 5 Q