3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ResourceType { public function __destruct() { echo "Resource is released.\n"; } } function get_callback() { $some_resource = new ResourceType(); $fn = function() use ($some_resource) { // this line does nothing // it overwrites a local variable which is never read // next time the closure runs, it will start again as the captured value $some_resource = null; }; return $fn; } $fn = get_callback(); echo "Before callback\n"; $fn(); echo "After callback\n"; unset($some_resource); echo "After destroying outer var\n"; // the captured reference is still live here; only destroying the closure frees it unset($fn); echo "After destroying closure\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.0120.00316.75
8.3.50.0070.00720.34
8.3.40.0180.00018.55
8.3.30.0160.00618.67
8.3.20.0080.00024.18
8.3.10.0040.00424.66
8.3.00.0050.00326.16
8.2.180.0040.01125.92
8.2.170.0110.00422.96
8.2.160.0160.00322.96
8.2.150.0000.00825.66
8.2.140.0070.00024.66
8.2.130.0080.00026.16
8.2.120.0050.00319.23
8.2.110.0060.00321.07
8.2.100.0030.00917.72
8.2.90.0000.00817.84
8.2.80.0080.00019.01
8.2.70.0000.00817.63
8.2.60.0060.00318.04
8.2.50.0030.00618.07
8.2.40.0000.00818.16
8.2.30.0000.00817.95
8.2.20.0030.00520.52
8.2.10.0040.00418.19
8.2.00.0070.00019.23
8.1.280.0100.00725.92
8.1.270.0050.00323.99
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0070.00422.07
8.1.230.0080.00320.97
8.1.220.0080.00017.78
8.1.210.0030.00618.77
8.1.200.0000.01017.48
8.1.190.0040.00417.35
8.1.180.0090.00018.10
8.1.170.0050.00318.49
8.1.160.0000.00718.84
8.1.150.0040.00418.64
8.1.140.0040.00417.57
8.1.130.0000.00717.40
8.1.120.0050.00317.52
8.1.110.0050.00517.48
8.1.100.0030.00617.35
8.1.90.0000.00717.49
8.1.80.0000.00817.33
8.1.70.0090.00517.37
8.1.60.0070.00417.50
8.1.50.0080.00317.45
8.1.40.0080.00517.50
8.1.30.0090.00417.60
8.1.20.0070.00617.66
8.1.10.0090.00417.54
8.1.00.0120.00317.47
8.0.300.0080.00019.86
8.0.290.0040.00416.63
8.0.280.0030.00318.36
8.0.270.0030.00316.82
8.0.260.0030.00316.81
8.0.250.0000.00716.90
8.0.240.0070.00016.95
8.0.230.0030.00316.92
8.0.220.0030.00316.79
8.0.210.0070.00016.88
8.0.200.0060.00516.92
8.0.190.0100.00216.88
8.0.180.0090.00616.79
8.0.170.0090.00616.83
8.0.160.0100.00516.78
8.0.150.0090.00616.82
8.0.140.0100.00516.79
8.0.130.0110.00416.78
8.0.120.0110.00416.86
8.0.110.0130.00116.82
8.0.100.0090.00716.75
8.0.90.0110.00316.88
8.0.80.0110.00416.76
8.0.70.0110.00516.75
8.0.60.0140.00116.74
8.0.50.0100.00516.77
8.0.30.0090.00516.79
8.0.20.0100.00416.91
8.0.10.0080.00616.99
7.4.330.0030.00315.55
7.4.320.0030.00316.60
7.4.300.0100.00416.51
7.4.290.0100.00416.54
7.4.280.0100.00516.52
7.4.270.0140.00116.52
7.4.260.0110.00616.50
7.4.250.0100.00516.53
7.4.240.0110.00516.54
7.4.230.0120.00416.55
7.4.220.0110.00316.39
7.4.210.0070.00516.46
7.4.200.0080.00316.42
7.4.190.0090.00316.46
7.4.180.0070.00516.41
7.4.160.0110.00216.33
7.4.150.0080.00516.44
7.4.140.0080.00516.34
7.4.130.0080.00416.33
7.4.120.0070.00416.32
7.4.110.0060.00316.35
7.4.100.0050.00416.35
7.4.90.0040.00516.33
7.4.80.0020.00616.28
7.4.70.0020.00516.24
7.4.60.0070.00116.44
7.4.50.0030.00416.26
7.4.40.0030.00516.32
7.4.30.0040.00416.39
7.4.20.0070.00316.46
7.4.10.0060.00316.43
7.4.00.0050.00416.43

preferences:
55.67 ms | 400 KiB | 5 Q