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); var_dump($this); }; $x->bindTo(new TestClass, "TestClass"); $x(); 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; var_dump($func->getClosureThis()); $source = file($filename); $body = implode("", array_slice($source, $start_line, $length)); $body = preg_replace('/(?:(?:(\$[a-z]+)\s\=)|return)\sfunction/', '\\$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]; } $body = str_replace(" use (" . $vars . ")", "", $body); } else { $parts = []; } if(strpos($body, '$this') !== false) { $parts[] = '$this'; $args[count($parts) - 1] = $func->getClosureThis(); } $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("{\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.3.60.0070.00716.75
8.3.50.0110.00417.92
8.3.40.0180.00418.83
8.3.30.0110.00418.70
8.3.20.0000.00720.34
8.3.10.0040.00423.53
8.3.00.0040.00419.85
8.2.180.0080.00818.38
8.2.170.0110.00422.96
8.2.160.0100.00320.47
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0040.00719.33
8.2.120.0050.00326.35
8.2.110.0030.00619.21
8.2.100.0060.00617.84
8.2.90.0000.00819.23
8.2.80.0090.00017.97
8.2.70.0070.00317.49
8.2.60.0040.00417.93
8.2.50.0040.00418.07
8.2.40.0030.00622.24
8.2.30.0000.00720.73
8.2.20.0000.00717.75
8.2.10.0080.00018.24
8.2.00.0030.00518.09
8.1.280.0040.01125.92
8.1.270.0000.00820.55
8.1.260.0000.00828.09
8.1.250.0030.00528.09
8.1.240.0070.00320.97
8.1.230.0090.00317.42
8.1.220.0080.00018.01
8.1.210.0080.00018.77
8.1.200.0100.00017.47
8.1.190.0000.00817.47
8.1.180.0000.00818.10
8.1.170.0000.00718.78
8.1.160.0070.00020.85
8.1.150.0000.00718.94
8.1.140.0030.00519.64
8.1.130.0040.00417.76
8.1.120.0040.00417.52
8.1.110.0000.00717.55
8.1.100.0000.00917.41
8.1.90.0070.00017.59
8.1.80.0000.00917.39
8.1.70.0030.00317.46
8.1.60.0040.00417.64
8.1.50.0030.00517.56
8.1.40.0040.00417.57
8.1.30.0040.00717.71
8.1.20.0000.00717.71
8.1.10.0000.00717.70
8.1.00.0080.00017.46
8.0.300.0080.00018.77
8.0.290.0000.00716.59
8.0.280.0000.00718.50
8.0.270.0030.00317.32
8.0.260.0000.00617.18
8.0.250.0070.00017.06
8.0.240.0070.00017.00
8.0.230.0030.00317.04
8.0.220.0000.00816.90
8.0.210.0030.00416.92
8.0.200.0060.00017.09
8.0.190.0040.00716.99
8.0.180.0040.00416.92
8.0.170.0030.00516.95
8.0.160.0000.00716.98
8.0.150.0040.00417.07
8.0.140.0000.00717.00
8.0.130.0040.00413.47
8.0.120.0000.00816.97
8.0.110.0040.00417.01
8.0.100.0000.00716.99
8.0.90.0050.00217.07
8.0.80.0030.01217.00
8.0.70.0060.00317.05
8.0.60.0050.00316.86
8.0.50.0000.00816.89
8.0.30.0050.01217.15
8.0.20.0140.00517.41
8.0.10.0000.00717.11
8.0.00.0060.01216.93
7.4.330.0050.00016.66
7.4.320.0000.00616.55
7.4.300.0000.00616.65
7.4.290.0000.00716.46
7.4.280.0040.00416.68
7.4.270.0000.00716.52
7.4.260.0080.00016.57
7.4.250.0070.00016.58
7.4.240.0010.00716.65
7.4.230.0030.00316.68
7.4.220.0070.01716.65
7.4.210.0100.00816.55
7.4.200.0040.00416.47
7.4.160.0030.01316.49
7.4.150.0170.00017.40
7.4.140.0110.01217.86
7.4.130.0140.00616.68
7.4.120.0120.01016.53
7.4.110.0070.01016.45
7.4.100.0100.00716.45
7.4.90.0030.02016.62
7.4.80.0110.00719.39
7.4.70.0150.00316.58
7.4.60.0110.00716.54
7.4.50.0070.00716.43
7.4.40.0050.01116.58
7.4.30.0090.01216.75
7.4.00.0000.01615.23
7.3.330.0020.00413.26
7.3.320.0000.00613.26
7.3.310.0000.00716.39
7.3.300.0070.00016.39
7.3.290.0000.00716.44
7.3.280.0060.01216.40
7.3.270.0120.00817.40
7.3.260.0090.01516.38
7.3.250.0130.00916.66
7.3.240.0140.00616.39
7.3.230.0100.00716.49
7.3.210.0100.01316.47
7.3.200.0090.00816.36
7.3.190.0030.01416.58
7.3.180.0100.00716.56
7.3.170.0090.01316.59
7.3.160.0110.00516.61
7.2.330.0070.01116.78
7.2.320.0080.01716.79
7.2.310.0060.01616.88
7.2.300.0080.01116.86
7.2.290.0130.00516.76
7.2.60.0030.01317.06
7.2.00.0030.00919.33
7.1.200.0030.01015.79
7.1.100.0100.00718.24
7.1.70.0050.00317.26
7.1.60.0090.01519.52
7.1.50.0180.00934.80
7.1.00.0130.06722.45
7.0.200.0030.00716.90
7.0.60.0100.07320.04
7.0.50.0070.04718.01
7.0.40.0030.04720.13
7.0.30.0270.08020.27
7.0.20.0300.06320.17
7.0.10.0070.09020.25
7.0.00.0070.08320.12
5.6.280.0030.03321.12
5.6.210.0100.07720.77
5.6.200.0100.07318.19
5.6.190.0100.03720.48
5.6.180.0330.06720.57
5.6.170.0300.06320.55
5.6.160.0170.07320.55
5.6.150.0070.04318.19
5.6.140.0070.06018.18
5.6.130.0000.04318.24
5.6.120.0100.07321.17
5.6.110.0200.07321.04
5.6.100.0100.03720.91
5.6.90.0100.08020.99
5.6.80.0030.04720.45
5.5.350.0130.08020.42
5.5.340.0070.04018.04
5.5.330.0030.08320.47
5.5.320.0130.08720.38
5.5.310.0330.06320.34
5.5.300.0100.05317.99
5.5.290.0100.07717.98
5.5.280.0030.06720.91
5.5.270.0130.07720.80
5.5.260.0100.07020.88
5.5.250.0130.07720.47
5.5.240.0300.07320.03

preferences:
50.52 ms | 400 KiB | 5 Q