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.3.60.0100.01318.40
8.3.50.0100.01018.32
8.3.40.0110.00418.79
8.3.30.0090.00618.84
8.3.20.0060.00320.11
8.3.10.0070.00721.32
8.3.00.0060.00719.88
8.2.180.0170.00718.54
8.2.170.0110.00419.04
8.2.160.0130.00719.46
8.2.150.0060.00325.66
8.2.140.0080.00522.54
8.2.130.0080.00519.38
8.2.120.0110.00222.75
8.2.110.0070.00719.88
8.2.100.0110.00418.51
8.2.90.0090.00519.13
8.2.80.0080.00618.54
8.2.70.0060.00618.20
8.2.60.0050.00718.41
8.2.50.0010.00718.50
8.2.40.0110.00219.17
8.2.30.0060.00518.61
8.2.20.0030.00618.25
8.2.10.0040.00617.95
8.2.00.0080.00518.20
8.1.280.0060.00925.92
8.1.270.0070.00722.73
8.1.260.0040.00824.14
8.1.250.0030.00525.08
8.1.240.0060.00321.35
8.1.230.0100.00020.62
8.1.220.0080.00418.32
8.1.210.0060.00618.68
8.1.200.0050.00518.09
8.1.190.0020.00618.08
8.1.180.0020.00618.24
8.1.170.0020.00618.51
8.1.160.0070.00418.39
8.1.150.0060.00518.21
8.1.140.0070.00418.61
8.1.130.0050.00617.92
8.1.120.0050.00617.78
8.1.110.0050.00617.67
8.1.100.0080.00417.71
8.1.90.0100.00217.67
8.1.80.0080.00417.71
8.1.70.0080.00517.71
8.1.60.0090.00317.79
8.1.50.0080.00417.73
8.1.40.0080.00517.69
8.1.30.0120.00317.80
8.1.20.0070.00717.77
8.1.10.0090.00417.68
8.1.00.0080.00717.71
8.0.300.0050.00218.38
8.0.290.0080.00417.41
8.0.280.0070.00418.05
8.0.270.0070.00417.53
8.0.260.0080.00417.53
8.0.250.0080.00417.65
8.0.240.0130.00217.45
8.0.230.0080.00417.27
8.0.220.0080.00317.30
8.0.210.0090.00417.27
8.0.200.0090.00217.36
8.0.190.0070.00317.23
8.0.180.0060.00417.30
8.0.170.0090.00517.26
8.0.160.0080.00517.27
8.0.150.0100.00417.17
8.0.140.0090.00517.24
8.0.130.0100.00316.61
8.0.120.0100.00416.29
8.0.110.0100.00316.30
8.0.100.0110.00416.29
8.0.90.0110.00517.19
8.0.80.0120.00517.23
8.0.70.0090.00617.23
8.0.60.0120.00317.20
8.0.50.0090.00617.22
8.0.30.0130.00617.20
8.0.20.0120.00517.36
8.0.10.0110.00417.22
8.0.00.0100.00417.38
7.4.330.0090.00215.72
7.4.320.0120.00417.09
7.4.300.0080.00516.93
7.4.290.0090.00516.92
7.4.280.0080.00316.83
7.4.270.0120.00216.87
7.4.260.0080.00516.88
7.4.250.0080.00515.96
7.4.240.0090.00416.86
7.4.230.0080.00616.90
7.4.220.0090.00616.94
7.4.210.0120.00516.85
7.4.200.0110.00316.85
7.4.190.0140.00416.98
7.4.180.0110.00417.01
7.4.160.0090.00516.82
7.4.150.0110.00416.96
7.4.140.0080.00717.26
7.4.130.0100.00616.84
7.4.120.0110.00616.77
7.4.110.0090.00716.85
7.4.100.0100.00616.84
7.4.90.0080.00616.88
7.4.80.0110.00617.15
7.4.70.0110.00516.78
7.4.60.0090.00516.78
7.4.50.0110.00516.72
7.4.40.0110.00516.71
7.4.30.0100.00516.71
7.4.20.0110.00516.70
7.4.10.0110.00616.80
7.4.00.0090.00716.57
7.3.330.0130.00416.58
7.3.320.0090.00616.30
7.3.310.0120.00516.76
7.3.300.0130.00416.90
7.3.290.0130.00616.81
7.3.280.0120.00616.70
7.3.270.0160.00417.02
7.3.260.0150.00516.77
7.3.250.0110.01016.69
7.3.240.0120.00616.73
7.3.230.0130.00716.74
7.3.220.0150.00516.73
7.3.210.0110.01016.67
7.3.200.0150.00616.75
7.3.190.0130.00516.67
7.3.180.0150.00416.69
7.3.170.0130.00416.80
7.3.160.0120.00716.69
7.3.150.0110.00816.68
7.3.140.0130.00616.67
7.3.130.0130.00516.79
7.3.120.0110.00616.65
7.3.110.0110.00616.74
7.3.100.0130.00416.64
7.3.90.0090.00616.83
7.3.80.0080.00716.78
7.3.70.0100.00516.73
7.3.60.0090.00616.76
7.3.50.0110.00516.77
7.3.40.0110.00516.76
7.3.30.0140.00516.70
7.3.20.0150.00517.30
7.3.10.0130.00717.23
7.3.00.0130.00517.22
7.2.340.0100.00716.89
7.2.330.0120.00616.77
7.2.320.0100.00716.80
7.2.310.0080.01016.78
7.2.300.0150.00516.77
7.2.290.0130.00716.81
7.2.280.0150.00616.79
7.2.270.0150.00516.88
7.2.260.0130.00816.80
7.2.250.0140.00716.79
7.2.240.0160.00516.76
7.2.230.0160.00516.84
7.2.220.0120.00816.78
7.2.210.0120.00616.82
7.2.200.0120.00716.95
7.2.190.0130.00516.87
7.2.180.0110.00616.90
7.2.170.0150.00416.89
7.2.160.0100.00716.86
7.2.150.0140.00517.36
7.2.140.0120.00817.43
7.2.130.0120.00617.50
7.2.120.0100.00917.47
7.2.110.0160.00517.53
7.2.100.0110.01017.44
7.2.90.0170.00517.43
7.2.80.0200.00617.38
7.2.70.0150.00617.46
7.2.60.0150.00617.33
7.2.50.0140.00717.44
7.2.40.0160.00617.46
7.2.30.0150.00617.47
7.2.20.0220.00517.44
7.2.10.0150.00717.43
7.2.00.0150.00517.43
7.1.330.0140.00616.56
7.1.320.0160.00316.52
7.1.310.0130.00616.54
7.1.300.0150.00516.55
7.1.290.0180.00216.59
7.1.280.0160.00316.54
7.1.270.0130.00716.65
7.1.260.0150.00516.50
7.1.250.0160.00316.40
7.1.240.0130.00516.45
7.1.230.0130.00416.50
7.1.220.0100.00716.52
7.1.210.0200.00416.54
7.1.200.0130.00616.33
7.1.190.0160.00516.49
7.1.180.0140.00516.46
7.1.170.0110.00716.46
7.1.160.0100.00816.42
7.1.150.0110.00616.42
7.1.140.0140.00616.44
7.1.130.0120.00616.44
7.1.120.0130.00716.46
7.1.110.0150.00616.50
7.1.100.0490.00616.45
7.1.90.0600.00616.43
7.1.80.0680.00716.42
7.1.70.0600.00516.23
7.1.60.0660.00720.19
7.1.50.0630.00720.16
7.1.40.0560.00620.07
7.1.30.0610.00820.07
7.1.20.0530.00920.17
7.1.10.0480.00616.13
7.1.00.0540.00716.05
7.0.330.0150.00616.22
7.0.320.0110.00716.28
7.0.310.0090.00816.18
7.0.300.0120.00816.27
7.0.290.0090.00816.24
7.0.280.0130.00416.23
7.0.270.0130.00516.26
7.0.260.0160.00516.29
7.0.250.0110.00616.30
7.0.240.0390.00516.23
7.0.230.0450.00716.23
7.0.220.0660.00616.25
7.0.210.0510.00516.08
7.0.200.0730.00616.01
7.0.190.0740.00615.96
7.0.180.0560.00715.81
7.0.170.0600.00515.87
7.0.160.0500.00615.84
7.0.150.0470.00715.84
7.0.140.0510.00615.88
7.0.130.0630.00815.95
7.0.120.0510.00615.94
7.0.110.0560.00515.89
7.0.100.0540.00715.79
7.0.90.0540.00615.81
7.0.80.0520.00715.84
7.0.70.0490.00715.83
7.0.60.0510.00815.81
7.0.50.0520.00615.84
7.0.40.0500.00715.89
7.0.30.0460.00515.90
7.0.20.0500.00715.90
7.0.10.0710.00715.90
7.0.00.0440.00715.89
5.6.400.0110.00515.77
5.6.390.0120.00616.37
5.6.380.0100.00616.36
5.6.370.0110.00616.30
5.6.360.0130.00416.33
5.6.350.0110.00616.24
5.6.340.0110.00616.25
5.6.330.0100.00616.30
5.6.320.0100.00616.35
5.6.310.0080.00816.28
5.6.300.0130.01917.28
5.6.290.0110.02117.27
5.6.280.0110.02317.39
5.6.270.0100.02017.37
5.6.260.0120.01917.33
5.6.250.0110.02017.36
5.6.240.0120.02017.36
5.6.230.0130.01717.44
5.6.220.0090.02217.37
5.6.210.0090.02217.31
5.6.200.0110.01917.35
5.6.190.0090.02217.34
5.6.180.0120.02117.39
5.6.170.0090.02117.33
5.6.160.0110.02117.36
5.6.150.0130.01817.33
5.6.140.0120.01917.37
5.6.130.0120.01717.34
5.6.120.0110.01917.29
5.6.110.0120.01917.29
5.6.100.0100.02217.32
5.6.90.0120.01817.29
5.6.80.0110.01717.17
5.6.70.0130.01717.26
5.6.60.0110.02117.19
5.6.50.0090.02117.05
5.6.40.0100.02117.11
5.6.30.0110.01817.15
5.6.20.0120.01617.13
5.6.10.0110.01717.10
5.6.00.0110.01917.08

preferences:
57.97 ms | 401 KiB | 5 Q