3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestClass { } $abc = "testABC"; $xyz = new TestClass(); $test = true; $x = function () use ($test, $xyz, $abc) { echo $abc; var_dump($test, $xyz); }; echo packAnonFunction($x, $test, $xyz, $abc); function packAnonFunction($payload, ...$args) { $func = new ReflectionFunction($payload); $filename = $func->getFileName(); $start_line = $func->getStartLine() - 1; $end_line = $func->getEndLine(); $length = $end_line - $start_line; $source = file($filename); $body = implode("", array_slice($source, $start_line, $length)); $body = preg_replace('/(\$[a-z]+)\ \=\ function/', '\\$payload = function', $body); if(preg_match('/use\s\((\$[a-zA-Z0-9]+(?:,\s\$[a-zA-Z0-9]+)*)\)/', $body, $matches)) { $vars = $matches[1]; if(strpos($vars, ', ') !== false) { $parts = explode(', ', $vars); } else { $parts = [$vars]; } $return = []; foreach($parts as $key => $variable) { $return[$variable] = $args[$key]; } $variableString = ""; foreach($return as $var => $value) { $value = serialize($value); $variableString .= "\t{$var} = unserialize('{$value}');\n"; } $body = str_replace(" use (" . $vars . ")", "", $body); $body = str_replace("{\n", "{\n" . $variableString, $body); } return $body; }

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.0130.00720.24
8.5.00.0120.01120.39
8.4.150.0030.00014.05
8.4.140.0160.00817.69
8.4.130.0120.00918.13
8.4.120.0100.00920.60
8.4.110.0080.00424.03
8.4.100.0140.00717.96
8.4.90.0120.00920.62
8.4.80.0060.00219.07
8.4.70.0090.01118.75
8.4.60.0100.00718.76
8.4.50.0120.00820.78
8.4.40.0160.00618.86
8.4.30.0030.00617.85
8.4.20.0030.01717.92
8.4.10.0170.00317.70
8.3.280.0120.01118.56
8.3.270.0100.00916.81
8.3.260.0150.00516.77
8.3.250.0090.01021.23
8.3.240.0100.00716.88
8.3.230.0120.00716.89
8.3.220.0080.01120.93
8.3.210.0100.00618.53
8.3.200.0050.00616.76
8.3.190.0070.00817.13
8.3.180.0080.01119.12
8.3.170.0070.01117.28
8.3.160.0120.00621.07
8.3.150.0100.01017.28
8.3.140.0080.01119.18
8.3.130.0040.00418.50
8.3.120.0060.00918.88
8.3.110.0040.00420.94
8.3.100.0160.00024.06
8.3.90.0180.00026.77
8.3.80.0060.01216.88
8.3.70.0040.01518.68
8.3.60.0070.01116.75
8.3.50.0100.00821.24
8.3.40.0090.00918.90
8.3.30.0120.00318.96
8.3.20.0040.00420.16
8.3.10.0080.00023.57
8.3.00.0080.00019.91
8.2.290.0110.00816.94
8.2.280.0120.00818.70
8.2.270.0110.00721.02
8.2.260.0080.00016.99
8.2.250.0040.01116.77
8.2.240.0030.00618.94
8.2.230.0060.00322.58
8.2.220.0070.00337.54
8.2.210.0060.00326.77
8.2.200.0030.00616.88
8.2.190.0200.00316.63
8.2.180.0110.01418.66
8.2.170.0060.00919.25
8.2.160.0120.00322.96
8.2.150.0090.00024.18
8.2.140.0080.00024.66
8.2.130.0030.00619.39
8.2.120.0040.00426.35
8.2.110.0080.00020.38
8.2.100.0110.00018.05
8.2.90.0040.00419.48
8.2.80.0050.00317.97
8.2.70.0030.00617.88
8.2.60.0060.00317.89
8.2.50.0030.00618.07
8.2.40.0060.00322.54
8.2.30.0040.00420.58
8.2.20.0040.00418.01
8.2.10.0050.00318.34
8.2.00.0070.00018.29
8.1.330.0110.00722.22
8.1.320.0110.00916.54
8.1.310.0090.00017.05
8.1.300.0030.00618.31
8.1.290.0060.00318.88
8.1.280.0110.00825.92
8.1.270.0060.00920.57
8.1.260.0040.00428.09
8.1.250.0040.00428.09
8.1.240.0060.00323.98
8.1.230.0040.00817.96
8.1.220.0030.00917.74
8.1.210.0060.00318.77
8.1.200.0000.00917.60
8.1.190.0030.00517.60
8.1.180.0050.00318.10
8.1.170.0000.00818.89
8.1.160.0040.00420.80
8.1.150.0020.00518.98
8.1.140.0060.00319.57
8.1.130.0000.00717.70
8.1.120.0030.00517.71
8.1.110.0000.00717.58
8.1.100.0070.00317.63
8.1.90.0040.00417.66
8.1.80.0030.00517.66
8.1.70.0040.00417.57
8.1.60.0000.00817.84
8.1.50.0030.00617.62
8.1.40.0000.00917.74
8.1.30.0040.00417.70
8.1.20.0080.00017.86
8.1.10.0030.00517.77
8.1.00.0040.00417.63
8.0.300.0040.00418.77
8.0.290.0100.00017.00
8.0.280.0040.00418.56
8.0.270.0040.00417.31
8.0.260.0070.00017.24
8.0.250.0070.00017.07
8.0.240.0070.00017.16
8.0.230.0040.00417.14
8.0.220.0040.00417.11
8.0.210.0000.00917.08
8.0.200.0080.00017.16
8.0.190.0100.00017.19
8.0.180.0000.00717.00
8.0.170.0050.00217.04
8.0.160.0000.00717.18
8.0.150.0030.00617.01
8.0.140.0030.00516.96
8.0.130.0060.00013.50
8.0.120.0050.00317.05
8.0.110.0030.00517.12
8.0.100.0040.00417.07
8.0.90.0040.00416.92
8.0.80.0070.00917.05
8.0.70.0040.00417.05
8.0.60.0000.00717.02
8.0.50.0000.00717.00
8.0.30.0130.00517.44
8.0.20.0070.01217.46
8.0.10.0000.00817.23
8.0.00.0090.00917.11
7.4.330.0050.00016.84
7.4.320.0030.00316.77
7.4.300.0070.00216.87
7.4.290.0030.00316.77
7.4.280.0050.00316.87
7.4.270.0000.00816.79
7.4.260.0050.00216.75
7.4.250.0040.00416.75
7.4.240.0030.00416.70
7.4.230.0000.00716.95
7.4.220.0070.01116.80
7.4.210.0090.00916.71
7.4.200.0000.00716.66
7.4.160.0100.00716.83
7.4.150.0140.00417.40
7.4.140.0100.01217.86
7.4.130.0130.00416.62
7.4.120.0070.01016.80
7.4.110.0080.01216.62
7.4.100.0140.00316.75
7.4.90.0080.01116.79
7.4.80.0140.00719.39
7.4.70.0190.00416.55
7.4.60.0140.00416.99
7.4.50.0040.01116.71
7.4.40.0120.00816.69
7.4.30.0080.00916.68
7.4.00.0000.01615.05
7.3.330.0030.00313.63
7.3.320.0070.00013.59
7.3.310.0040.00416.67
7.3.300.0000.00716.43
7.3.290.0080.00716.52
7.3.280.0090.00916.53
7.3.270.0070.01017.40
7.3.260.0090.00916.59
7.3.250.0080.01316.57
7.3.240.0090.00816.58
7.3.230.0110.00616.77
7.3.210.0150.00316.62
7.3.200.0060.01116.95
7.3.190.0090.00916.80
7.3.180.0080.00816.66
7.3.170.0050.01416.74
7.3.160.0030.01216.86
7.2.330.0060.01217.05
7.2.320.0030.02217.09
7.2.310.0090.01216.89
7.2.300.0120.00616.83
7.2.290.0100.00917.05
7.2.110.0170.00716.71
7.2.60.0060.00617.25
7.2.00.0120.00419.96
7.1.200.0000.01316.13
7.1.100.0620.01016.02
7.1.70.0030.01017.26
7.1.60.0060.00919.52
7.1.50.0130.01017.36
7.1.00.0030.07722.44
7.0.200.0030.00617.04
7.0.60.0070.08719.90
7.0.50.0070.06017.95
7.0.40.0070.04320.43
7.0.30.0270.08320.13
7.0.20.0400.07020.35
7.0.10.0130.08020.25
7.0.00.0100.05020.16
5.6.210.0100.05720.61
5.6.200.0070.06318.17
5.6.190.0100.08720.77
5.6.180.0300.08320.67
5.6.170.0430.06020.39
5.6.160.0100.08020.43
5.6.150.0070.08018.15
5.6.140.0030.07718.17
5.6.130.0030.08718.13
5.6.120.0070.05021.04
5.6.110.0230.06721.14
5.6.100.0130.06720.98
5.6.90.0100.08321.08
5.6.80.0070.07020.55
5.5.350.0130.06720.43
5.5.340.0030.04018.05
5.5.330.0070.09020.31
5.5.320.0430.06720.38
5.5.310.0230.05020.42
5.5.300.0070.06318.01
5.5.290.0000.08317.95
5.5.280.0130.07020.81
5.5.270.0030.08320.96
5.5.260.0070.05020.74
5.5.250.0100.07720.79
5.5.240.0200.04320.13

preferences:
165.06 ms | 403 KiB | 5 Q