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.10.0040.00316.94
8.5.00.0160.00818.79
8.4.150.0150.00416.89
8.4.140.0200.00617.85
8.4.130.0160.00518.73
8.4.120.0140.00920.09
8.4.110.0140.00818.51
8.4.100.0150.00817.99
8.4.90.0170.00619.23
8.4.80.0160.01119.11
8.4.70.0210.00618.44
8.4.60.0200.00719.32
8.4.50.0200.00819.13
8.4.40.0190.00918.77
8.4.30.0120.00517.83
8.4.20.0240.00518.19
8.4.10.0160.00218.81
8.3.280.0150.01018.51
8.3.270.0210.00617.11
8.3.260.0240.00717.02
8.3.250.0250.00718.05
8.3.240.0260.00818.22
8.3.230.0170.00917.14
8.3.220.0250.00718.24
8.3.210.0240.00617.05
8.3.200.0200.00617.05
8.3.190.0180.00817.35
8.3.180.0210.00518.27
8.3.170.0250.00817.33
8.3.160.0200.00617.95
8.3.150.0180.00517.37
8.3.140.0240.00317.01
8.3.130.0130.00317.73
8.3.120.0160.00418.15
8.3.110.0200.00817.90
8.3.100.0190.00520.71
8.3.90.0280.00422.07
8.3.80.0200.00517.90
8.3.70.0200.00817.18
8.3.60.0240.01117.88
8.3.50.0210.01217.45
8.3.40.0180.00518.30
8.3.30.0180.00918.36
8.3.20.0200.00619.04
8.3.10.0140.00720.25
8.3.00.0130.00619.16
8.2.290.0170.00917.26
8.2.280.0170.00817.91
8.2.270.0170.00517.04
8.2.260.0140.01218.17
8.2.250.0180.00518.03
8.2.240.0140.00517.28
8.2.230.0170.00319.15
8.2.220.0190.00827.45
8.2.210.0110.00522.07
8.2.200.0120.00417.12
8.2.190.0130.00617.93
8.2.180.0180.00417.95
8.2.170.0130.00518.57
8.2.160.0220.00718.80
8.2.150.0120.00721.73
8.2.140.0130.00520.94
8.2.130.0110.00418.91
8.2.120.0130.00221.17
8.2.110.0090.00619.27
8.2.100.0130.00518.33
8.2.90.0090.00618.71
8.2.80.0100.00618.34
8.2.70.0080.00618.03
8.2.60.0090.00518.22
8.2.50.0070.00718.29
8.2.40.0120.00418.77
8.2.30.0100.00518.42
8.2.20.0080.00618.13
8.2.10.0060.00617.94
8.2.00.0150.00518.07
8.1.330.0210.00716.92
8.1.320.0140.00918.75
8.1.310.0150.00517.98
8.1.300.0190.00817.86
8.1.290.0080.00724.10
8.1.280.0100.00721.64
8.1.270.0090.00721.73
8.1.260.0120.00822.00
8.1.250.0130.00522.66
8.1.240.0110.00520.14
8.1.230.0150.00319.57
8.1.220.0160.00418.10
8.1.210.0110.00618.32
8.1.200.0120.00517.92
8.1.190.0100.00717.91
8.1.180.0110.00518.04
8.1.170.0100.00718.21
8.1.160.0130.00518.20
8.1.150.0080.00518.05
8.1.140.0090.00518.34
8.1.130.0100.00717.87
8.1.120.0100.00617.77
8.1.110.0090.00617.64
8.1.100.0100.00517.72
8.1.90.0130.00417.64
8.1.80.0100.00417.67
8.1.70.0090.00417.70
8.1.60.0120.00517.75
8.1.50.0100.00517.70
8.1.40.0090.00517.71
8.1.30.0130.00317.80
8.1.20.0080.00717.77
8.1.10.0100.00417.70
8.1.00.0130.00817.69
8.0.300.0120.00418.04
8.0.290.0090.00517.40
8.0.280.0090.00517.88
8.0.270.0120.00517.49
8.0.260.0100.00417.49
8.0.250.0090.00417.58
8.0.240.0130.00217.43
8.0.230.0090.00417.29
8.0.220.0090.00417.31
8.0.210.0100.00417.28
8.0.200.0100.00317.36
8.0.190.0090.00317.25
8.0.180.0080.00417.31
8.0.170.0110.00517.27
8.0.160.0110.00617.28
8.0.150.0100.00417.19
8.0.140.0130.00617.26
8.0.130.0110.00316.72
8.0.120.0120.00416.41
8.0.110.0100.00416.42
8.0.100.0110.00416.41
8.0.90.0120.00517.22
8.0.80.0120.00517.25
8.0.70.0110.00517.25
8.0.60.0130.00317.22
8.0.50.0100.00517.24
8.0.30.0130.00617.22
8.0.20.0120.00517.36
8.0.10.0110.00517.24
8.0.00.0110.00417.38
7.4.330.0110.00316.13
7.4.320.0130.00417.15
7.4.300.0090.00617.01
7.4.290.0100.00517.00
7.4.280.0090.00316.91
7.4.270.0120.00316.94
7.4.260.0090.00516.95
7.4.250.0090.00516.12
7.4.240.0100.00416.93
7.4.230.0100.00616.96
7.4.220.0100.00617.00
7.4.210.0130.00516.92
7.4.200.0120.00316.92
7.4.190.0130.00417.04
7.4.180.0120.00417.07
7.4.160.0090.00516.89
7.4.150.0120.00517.02
7.4.140.0080.00717.28
7.4.130.0100.00616.90
7.4.120.0110.00616.83
7.4.110.0100.00716.92
7.4.100.0100.00616.91
7.4.90.0090.00616.94
7.4.80.0110.00617.18
7.4.70.0110.00516.85
7.4.60.0100.00516.85
7.4.50.0110.00516.80
7.4.40.0110.00416.79
7.4.30.0100.00516.79
7.4.20.0110.00416.78
7.4.10.0110.00616.87
7.4.00.0090.00716.66
7.3.330.0130.00416.66
7.3.320.0100.00516.46
7.3.310.0130.00516.85
7.3.300.0130.00416.97
7.3.290.0130.00516.88
7.3.280.0130.00616.78
7.3.270.0170.00417.07
7.3.260.0160.00516.85
7.3.250.0120.01016.76
7.3.240.0130.00616.80
7.3.230.0140.00616.81
7.3.220.0170.00616.82
7.3.210.0120.00916.76
7.3.200.0160.00616.82
7.3.190.0150.00616.76
7.3.180.0150.00416.77
7.3.170.0140.00416.87
7.3.160.0140.00716.77
7.3.150.0130.00716.76
7.3.140.0140.00616.76
7.3.130.0130.00516.86
7.3.120.0110.00616.74
7.3.110.0110.00516.82
7.3.100.0130.00416.73
7.3.90.0090.00616.90
7.3.80.0090.00716.85
7.3.70.0110.00516.81
7.3.60.0100.00616.83
7.3.50.0110.00516.85
7.3.40.0120.00516.83
7.3.30.0140.00616.78
7.3.20.0170.00517.31
7.3.10.0140.00717.24
7.3.00.0150.00517.24
7.2.340.0120.00716.96
7.2.330.0140.00616.84
7.2.320.0120.00716.87
7.2.310.0100.01016.86
7.2.300.0160.00516.84
7.2.290.0150.00716.88
7.2.280.0160.00616.86
7.2.270.0150.00516.94
7.2.260.0130.00816.87
7.2.250.0140.00716.87
7.2.240.0160.00516.83
7.2.230.0170.00516.91
7.2.220.0130.00816.86
7.2.210.0130.00616.89
7.2.200.0120.00717.00
7.2.190.0130.00616.93
7.2.180.0120.00616.96
7.2.170.0150.00416.95
7.2.160.0100.00716.92
7.2.150.0140.00517.36
7.2.140.0120.00817.42
7.2.130.0120.00617.48
7.2.120.0110.00817.46
7.2.110.0160.00517.51
7.2.100.0120.00917.43
7.2.90.0170.00517.42
7.2.80.0190.00617.38
7.2.70.0150.00617.45
7.2.60.0160.00517.33
7.2.50.0160.00620.11
7.2.40.0160.00617.45
7.2.30.0160.00617.46
7.2.20.0220.00517.43
7.2.10.0150.00717.42
7.2.00.0170.00617.42
7.1.330.0150.00616.66
7.1.320.0180.00416.62
7.1.310.0150.00616.64
7.1.300.0160.00516.65
7.1.290.0190.00316.68
7.1.280.0150.00316.64
7.1.270.0130.00716.74
7.1.260.0150.00516.61
7.1.250.0160.00316.52
7.1.240.0170.00516.57
7.1.230.0130.00416.61
7.1.220.0100.00716.63
7.1.210.0190.00416.65
7.1.200.0130.00516.44
7.1.190.0150.00516.60
7.1.180.0140.00516.57
7.1.170.0110.00616.57
7.1.160.0110.00716.54
7.1.150.0110.00616.53
7.1.140.0150.00616.56
7.1.130.0120.00616.56
7.1.120.0130.00716.57
7.1.110.0160.00616.61
7.1.100.0470.00616.55
7.1.90.0550.00616.54
7.1.80.0630.00616.52
7.1.70.0560.00516.34
7.1.60.0610.00719.91
7.1.50.0590.00719.88
7.1.40.0520.00619.80
7.1.30.0570.00819.80
7.1.20.0500.00919.90
7.1.10.0450.00616.25
7.1.00.0510.00616.20
7.0.330.0150.00616.37
7.0.320.0120.00616.42
7.0.310.0100.00716.33
7.0.300.0120.00716.41
7.0.290.0090.00716.38
7.0.280.0130.00516.37
7.0.270.0130.00516.39
7.0.260.0150.00416.43
7.0.250.0120.00516.43
7.0.240.0370.00516.36
7.0.230.0410.00716.35
7.0.220.0600.00616.37
7.0.210.0470.00416.22
7.0.200.0680.00616.15
7.0.190.0680.00616.10
7.0.180.0510.00615.97
7.0.170.0550.00516.02
7.0.160.0460.00616.00
7.0.150.0440.00715.99
7.0.140.0470.00516.02
7.0.130.0580.00816.09
7.0.120.0470.00516.08
7.0.110.0520.00516.04
7.0.100.0500.00715.95
7.0.90.0500.00515.96
7.0.80.0490.00715.99
7.0.70.0470.00715.98
7.0.60.0480.00815.96
7.0.50.0490.00615.99
7.0.40.0470.00616.04
7.0.30.0440.00616.04
7.0.20.0470.00716.04
7.0.10.0650.00716.05
7.0.00.0420.00716.04
5.6.400.0100.00515.90
5.6.390.0120.00616.47
5.6.380.0100.00616.49
5.6.370.0110.00616.44
5.6.360.0130.00416.46
5.6.350.0110.00616.38
5.6.340.0110.00616.39
5.6.330.0100.00616.43
5.6.320.0100.00616.48
5.6.310.0080.00816.42
5.6.300.0150.01817.28
5.6.290.0120.02017.28
5.6.280.0120.02117.38
5.6.270.0120.01917.37
5.6.260.0140.01817.33
5.6.250.0120.01817.36
5.6.240.0130.01917.36
5.6.230.0130.01617.44
5.6.220.0100.02017.37
5.6.210.0110.02017.31
5.6.200.0130.01817.35
5.6.190.0100.02117.34
5.6.180.0120.02017.38
5.6.170.0100.01917.33
5.6.160.0120.01917.36
5.6.150.0130.01717.34
5.6.140.0130.01817.37
5.6.130.0130.01617.34
5.6.120.0130.01817.30
5.6.110.0130.01717.30
5.6.100.0110.02017.33
5.6.90.0130.01817.30
5.6.80.0110.01617.19
5.6.70.0150.01617.27
5.6.60.0120.02017.21
5.6.50.0100.01917.08
5.6.40.0110.02017.14
5.6.30.0120.01717.17
5.6.20.0130.01517.15
5.6.10.0110.01517.13
5.6.00.0130.01817.10

preferences:
134.82 ms | 403 KiB | 5 Q