3v4l.org

run code in 300+ PHP versions simultaneously
<?php function closure_to_str($func) { $refl = new \ReflectionFunction($func); // get reflection object $path = $refl->getFileName(); // absolute path of php file $begn = $refl->getStartLine(); // have to `-1` for array index $endn = $refl->getEndLine(); $dlim = "\n"; // or PHP_EOL $list = explode($dlim, file_get_contents($path)); // lines of php-file source $list = array_slice($list, ($begn-1), ($endn-($begn-1))); // lines of closure definition $last = (count($list)-1); // last line number if((substr_count($list[0],'function')>1)|| (substr_count($list[0],'{')>1) || (substr_count($list[$last],'}')>1)) { throw new \Exception("Too complex context definition in: `$path`. Check lines: $begn & $endn."); } $list[0] = ('function'.explode('function',$list[0])[1]); $list[$last] = (explode('}',$list[$last])[0].'}'); return implode($list,$dlim); } $dog2 = ['bark'=>function($foo = '{'){}]; echo closure_to_str($dog2['bark'])."\n\n";

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.20.0240.00518.09
8.5.10.0220.00516.85
8.5.00.0180.00818.11
8.4.170.0230.00921.22
8.4.160.0220.01022.04
8.4.150.0220.00517.86
8.4.140.0240.00817.88
8.4.130.0230.00718.44
8.4.120.0230.01019.38
8.4.110.0210.00918.35
8.4.100.0230.00818.02
8.4.90.0260.00618.82
8.4.80.0230.01018.80
8.4.70.0280.00718.29
8.4.60.0260.00718.87
8.4.50.0240.00918.88
8.4.40.0260.00918.38
8.4.30.0210.00617.89
8.4.20.0270.00618.10
8.4.10.0240.00518.42
8.3.300.0220.00918.48
8.3.290.0240.01019.64
8.3.280.0240.01018.50
8.3.270.0270.00716.96
8.3.260.0300.00716.87
8.3.250.0280.00717.63
8.3.240.0290.00917.76
8.3.230.0240.00916.98
8.3.220.0290.00817.72
8.3.210.0260.00716.97
8.3.200.0250.00717.02
8.3.190.0200.00717.11
8.3.180.0200.00417.80
8.3.170.0280.00817.15
8.3.160.0260.00717.54
8.3.150.0240.00717.16
8.3.140.0290.00516.91
8.3.130.0160.00417.62
8.3.120.0240.00517.70
8.3.110.0260.00817.54
8.3.100.0250.00819.43
8.3.90.0320.00520.20
8.3.80.0270.00617.51
8.3.70.0270.00717.01
8.3.60.0300.01017.49
8.3.50.0270.01217.30
8.3.40.0250.00618.18
8.3.30.0220.00818.17
8.3.20.0240.00818.65
8.3.10.0190.00719.69
8.3.00.0170.00618.84
8.2.300.0270.01021.05
8.2.290.0200.01017.07
8.2.280.0210.00817.58
8.2.270.0230.00816.90
8.2.260.0200.01017.61
8.2.250.0230.00717.56
8.2.240.0180.00817.12
8.2.230.0230.00418.26
8.2.220.0220.00923.86
8.2.210.0170.00620.22
8.2.200.0180.00516.90
8.2.190.0180.00817.52
8.2.180.0210.00617.56
8.2.170.0180.00618.45
8.2.160.0230.01018.57
8.2.150.0170.00820.46
8.2.140.0180.00520.12
8.2.130.0160.00418.67
8.2.120.0170.00320.37
8.2.110.0130.00818.96
8.2.100.0180.00618.25
8.2.90.0140.00718.53
8.2.80.0150.00618.23
8.2.70.0140.00618.01
8.2.60.0140.00618.17
8.2.50.0120.00818.23
8.2.40.0180.00418.53
8.2.30.0140.00618.28
8.2.20.0140.00618.04
8.2.10.0080.00617.94
8.2.00.0170.00718.04
8.1.340.0220.00918.87
8.1.330.0240.00816.80
8.1.320.0180.00917.93
8.1.310.0210.00517.39
8.1.300.0250.00817.24
8.1.290.0160.00821.50
8.1.280.0170.00919.88
8.1.270.0130.00721.04
8.1.260.0170.00820.97
8.1.250.0170.00721.40
8.1.240.0160.00519.58
8.1.230.0180.00419.10
8.1.220.0200.00418.02
8.1.210.0150.00618.16
8.1.200.0160.00717.83
8.1.190.0140.00817.79
8.1.180.0140.00717.94
8.1.170.0160.00718.08
8.1.160.0160.00618.09
8.1.150.0130.00617.96
8.1.140.0120.00618.18
8.1.130.0140.00717.83
8.1.120.0130.00717.72
8.1.110.0110.00717.65
8.1.100.0120.00617.71
8.1.90.0150.00417.65
8.1.80.0120.00517.66
8.1.70.0130.00517.70
8.1.60.0130.00617.77
8.1.50.0150.00517.69
8.1.40.0120.00517.73
8.1.30.0150.00317.81
8.1.20.0100.00717.78
8.1.10.0120.00517.89
8.1.00.0150.00817.69
8.0.300.0150.00517.79
8.0.290.0140.00617.33
8.0.280.0120.00617.72
8.0.270.0150.00517.41
8.0.260.0110.00517.37
8.0.250.0100.00417.51
8.0.240.0160.00217.38
8.0.230.0120.00517.26
8.0.220.0120.00417.23
8.0.210.0120.00517.26
8.0.200.0120.00417.30
8.0.190.0110.00417.21
8.0.180.0100.00517.27
8.0.170.0130.00517.25
8.0.160.0130.00617.26
8.0.150.0120.00417.18
8.0.140.0140.00617.26
8.0.130.0130.00416.73
8.0.120.0130.00516.46
8.0.110.0120.00416.48
8.0.100.0130.00416.48
8.0.90.0140.00517.16
8.0.80.0150.00517.20
8.0.70.0120.00617.22
8.0.60.0140.00317.20
8.0.50.0120.00617.22
8.0.30.0150.00617.19
8.0.20.0140.00517.34
8.0.10.0140.00617.22
8.0.00.0120.00517.35
7.4.330.0140.00416.25
7.4.320.0150.00417.05
7.4.300.0110.00616.98
7.4.290.0130.00516.94
7.4.280.0120.00316.88
7.4.270.0140.00416.92
7.4.260.0110.00516.92
7.4.250.0110.00616.15
7.4.240.0130.00516.87
7.4.230.0130.00616.89
7.4.220.0130.00616.95
7.4.210.0160.00516.89
7.4.200.0140.00416.87
7.4.190.0160.00516.99
7.4.180.0150.00417.03
7.4.160.0120.00516.87
7.4.150.0140.00616.94
7.4.140.0100.00717.22
7.4.130.0110.00716.87
7.4.120.0130.00616.81
7.4.110.0120.00716.87
7.4.100.0120.00616.85
7.4.90.0110.00616.89
7.4.80.0130.00617.12
7.4.70.0130.00516.81
7.4.60.0120.00516.81
7.4.50.0130.00616.76
7.4.40.0130.00516.73
7.4.30.0120.00516.76
7.4.20.0130.00516.74
7.4.10.0130.00616.84
7.4.00.0110.00716.64
7.3.330.0140.00516.67
7.3.320.0120.00616.44
7.3.310.0160.00516.80
7.3.300.0150.00516.91
7.3.290.0150.00516.87
7.3.280.0140.00716.78
7.3.270.0180.00517.07
7.3.260.0170.00616.83
7.3.250.0130.01016.74
7.3.240.0140.00616.80
7.3.230.0160.00616.78
7.3.220.0180.00616.79
7.3.210.0140.00916.74
7.3.200.0180.00616.80
7.3.190.0160.00616.72
7.3.180.0160.00416.74
7.3.170.0150.00516.83
7.3.160.0150.00716.73
7.3.150.0140.00716.75
7.3.140.0150.00716.72
7.3.130.0140.00516.83
7.3.120.0130.00616.72
7.3.110.0130.00616.78
7.3.100.0140.00416.70
7.3.90.0110.00616.91
7.3.80.0110.00716.81
7.3.70.0120.00516.76
7.3.60.0110.00616.81
7.3.50.0120.00516.84
7.3.40.0130.00516.82
7.3.30.0150.00616.77
7.3.20.0190.00617.44
7.3.10.0160.00717.36
7.3.00.0170.00517.35
7.2.340.0130.00716.92
7.2.330.0150.00616.81
7.2.320.0140.00816.82
7.2.310.0120.01016.80
7.2.300.0180.00616.80
7.2.290.0170.00716.86
7.2.280.0180.00616.84
7.2.270.0160.00616.89
7.2.260.0140.00816.85
7.2.250.0160.00716.84
7.2.240.0170.00616.82
7.2.230.0180.00516.88
7.2.220.0140.00816.84
7.2.210.0140.00616.86
7.2.200.0140.00716.96
7.2.190.0140.00616.90
7.2.180.0130.00716.93
7.2.170.0160.00416.92
7.2.160.0130.00716.90
7.2.150.0170.00517.48
7.2.140.0130.00817.53
7.2.130.0130.00617.64
7.2.120.0120.00817.59
7.2.110.0170.00517.63
7.2.100.0130.00917.57
7.2.90.0180.00617.55
7.2.80.0200.00617.52
7.2.70.0170.00617.58
7.2.60.0170.00517.45
7.2.50.0170.00719.98
7.2.40.0180.00617.58
7.2.30.0170.00617.57
7.2.20.0230.00517.58
7.2.10.0160.00717.56
7.2.00.0180.00617.57
7.1.330.0160.00616.75
7.1.320.0190.00516.74
7.1.310.0160.00616.73
7.1.300.0170.00516.73
7.1.290.0200.00316.77
7.1.280.0160.00416.72
7.1.270.0150.00716.84
7.1.260.0160.00516.71
7.1.250.0170.00416.62
7.1.240.0180.00616.66
7.1.230.0140.00416.71
7.1.220.0120.00716.73
7.1.210.0200.00416.76
7.1.200.0140.00616.53
7.1.190.0160.00516.69
7.1.180.0150.00516.65
7.1.170.0130.00616.67
7.1.160.0130.00716.66
7.1.150.0130.00616.64
7.1.140.0160.00616.62
7.1.130.0140.00616.66
7.1.120.0150.00716.64
7.1.110.0170.00616.70
7.1.100.0450.00616.65
7.1.90.0520.00616.62
7.1.80.0590.00616.60
7.1.70.0530.00516.45
7.1.60.0580.00719.70
7.1.50.0560.00719.66
7.1.40.0490.00619.59
7.1.30.0540.00819.58
7.1.20.0480.00919.67
7.1.10.0430.00616.36
7.1.00.0480.00616.31
7.0.330.0160.00616.46
7.0.320.0130.00616.52
7.0.310.0110.00716.43
7.0.300.0130.00816.52
7.0.290.0110.00716.45
7.0.280.0140.00516.46
7.0.270.0140.00516.48
7.0.260.0160.00516.50
7.0.250.0130.00516.54
7.0.240.0350.00516.44
7.0.230.0390.00716.41
7.0.220.0570.00616.48
7.0.210.0450.00516.33
7.0.200.0640.00616.24
7.0.190.0640.00516.19
7.0.180.0480.00716.08
7.0.170.0530.00516.16
7.0.160.0450.00616.12
7.0.150.0420.00716.09
7.0.140.0440.00616.15
7.0.130.0550.00816.18
7.0.120.0450.00616.20
7.0.110.0490.00516.14
7.0.100.0480.00716.06
7.0.90.0480.00616.05
7.0.80.0460.00716.11
7.0.70.0450.00716.08
7.0.60.0460.00716.09
7.0.50.0470.00616.09
7.0.40.0440.00716.15
7.0.30.0420.00616.16
7.0.20.0450.00716.16
7.0.10.0610.00716.17
7.0.00.0400.00716.14
5.6.400.0120.00515.93
5.6.390.0130.00616.46
5.6.380.0120.00616.46
5.6.370.0130.00616.43
5.6.360.0140.00516.45
5.6.350.0130.00616.37
5.6.340.0130.00616.38
5.6.330.0120.00616.42
5.6.320.0120.00616.44
5.6.310.0100.00816.41
5.6.300.0150.01717.18
5.6.290.0130.01917.20
5.6.280.0130.02017.29
5.6.270.0130.01817.26
5.6.260.0150.01817.24
5.6.250.0140.01717.26
5.6.240.0140.01817.26
5.6.230.0140.01517.31
5.6.220.0110.01917.26
5.6.210.0120.01917.23
5.6.200.0140.01717.26
5.6.190.0120.02017.25
5.6.180.0140.01817.31
5.6.170.0110.01817.24
5.6.160.0140.01817.27
5.6.150.0150.01617.25
5.6.140.0140.01617.28
5.6.130.0140.01517.24
5.6.120.0140.01717.22
5.6.110.0140.01717.19
5.6.100.0120.01917.21
5.6.90.0140.01717.17
5.6.80.0130.01517.09
5.6.70.0160.01517.19
5.6.60.0130.01917.10
5.6.50.0110.01817.01
5.6.40.0120.01817.07
5.6.30.0130.01717.09
5.6.20.0140.01517.05
5.6.10.0120.01517.04
5.6.00.0130.01717.02

preferences:
33.15 ms | 403 KiB | 5 Q