3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $sum = null; // global variable function outer() { global $sum; $hundred_more = 100; $sum = function ($a, $b) use ($hundred_more) { return $a + $b + (++$hundred_more); }; $sum2 = function ($a, $b) use ($hundred_more) { return $a + $b + (++$hundred_more); }; var_dump($hundred_more); } outer(); // define sum at the global scope and print 100 var_dump($sum(5, 10)); // 116 var_dump($sum(5, 10)); // 117 var_dump($sum2(5, 10)); // 116 var_dump($sum2(5, 10)); // 117 outer(); // redefine sum at the global scope and print 100 var_dump($sum(5, 10)); // 116 var_dump($sum(5, 10)); // 117 var_dump($sum2(5, 10)); // 116 var_dump($sum2(5, 10)); // 117
based on XKE7j

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
7.3.0rc40.0160.00698.97
7.3.0rc30.0100.01016.52
7.3.0beta10.0000.01112.88
7.3.0alpha10.0050.00512.78
7.2.60.0070.00716.99
7.2.00.0000.01419.32
7.1.200.0070.00715.97
7.1.100.0070.00717.93
7.1.70.0100.00716.89
7.1.60.0100.01019.11
7.1.50.0170.02134.98
7.1.00.0030.07722.35
7.0.200.0030.00616.98
7.0.140.0000.08021.95
7.0.60.0130.07320.05
7.0.50.0030.08317.87
7.0.40.0070.06720.21
7.0.30.0300.07020.13
7.0.20.0130.05320.23
7.0.10.0030.04320.26
7.0.00.0000.07320.25
5.6.210.0000.04320.66
5.6.200.0070.08318.19
5.6.190.0030.08720.34
5.6.180.0270.05020.52
5.6.170.0230.04320.51
5.6.160.0070.03720.55
5.6.150.0030.05018.23
5.6.140.0030.07718.27
5.6.130.0070.04718.15
5.6.120.0100.06721.14
5.6.110.0070.08721.11
5.6.100.0130.07720.90
5.6.90.0100.03720.97
5.6.80.0000.08320.42
5.6.70.4570.04020.44
5.5.350.0070.08720.38
5.5.340.0130.07018.04
5.5.330.0030.08720.40
5.5.320.0070.05020.34
5.5.310.0200.03720.37
5.5.300.0100.06717.98
5.5.290.0100.08718.08
5.5.280.0030.08320.88
5.5.270.0100.08020.80
5.5.260.0100.08020.88
5.5.250.0100.03320.61
5.5.240.0300.06320.13
5.4.450.0800.06019.35
5.4.440.1200.06719.59
5.4.430.0030.06019.38
5.4.420.0670.00019.44
5.4.410.0670.00019.21
5.4.400.0600.00019.27
5.4.390.0600.00019.10
5.4.380.0630.00019.05
5.4.370.0630.00018.98
5.4.360.0670.00019.25
5.4.350.0670.00019.07
5.4.340.0060.03412.02
5.4.320.0020.04212.52
5.4.310.0060.04212.51
5.4.300.0050.04012.51
5.4.290.0060.03912.51
5.4.280.0040.03812.41
5.4.270.0090.03512.41
5.4.260.0080.03712.41
5.4.250.0060.03912.41
5.4.240.0070.03512.41
5.4.230.0060.04112.39
5.4.220.0060.04412.40
5.4.210.0080.03712.40
5.4.200.0050.03812.39
5.4.190.0080.03312.39
5.4.180.0060.03512.40
5.4.170.0050.04412.41
5.4.160.0050.04912.40
5.4.150.0060.04212.39
5.4.140.0070.03612.08
5.4.130.0060.03612.07
5.4.120.0020.03912.02
5.4.110.0030.03912.02
5.4.100.0060.03912.02
5.4.90.0050.04312.02
5.4.80.0070.03812.02
5.4.70.0030.04012.02
5.4.60.0090.03312.02
5.4.50.0060.03612.02
5.4.40.0110.03012.00
5.4.30.0060.03712.00
5.4.20.0040.03812.00
5.4.10.0090.03612.00
5.4.00.0070.04211.49
5.3.290.0080.04112.80
5.3.280.0070.03812.71
5.3.270.0060.03912.72
5.3.260.0070.03812.72
5.3.250.0060.04112.72
5.3.240.0070.03912.72
5.3.230.0050.04112.70
5.3.220.0070.03812.68
5.3.210.0080.04012.68
5.3.200.0110.03512.68
5.3.190.0130.03312.68
5.3.180.0100.04112.67
5.3.170.0090.04812.67
5.3.160.0070.04512.68
5.3.150.0070.04612.67
5.3.140.0030.04112.66
5.3.130.0080.04212.66
5.3.120.0090.04712.66
5.3.110.0070.05412.65
5.3.100.0100.04412.13
5.3.90.0060.03812.11
5.3.80.0020.04112.11
5.3.70.0110.03312.11
5.3.60.0070.03612.09
5.3.50.0070.03612.04
5.3.40.0080.04212.04
5.3.30.0100.03912.00
5.3.20.0090.03711.79
5.3.10.0070.03311.74
5.3.00.0050.03711.73
5.2.170.0070.0289.21
5.2.160.0060.0289.21
5.2.150.0070.0319.21
5.2.140.0060.0299.21
5.2.130.0070.0289.17
5.2.120.0090.0359.18
5.2.110.0070.0359.18
5.2.100.0070.0279.18
5.2.90.0080.0289.18
5.2.80.0060.0439.18
5.2.70.0090.0549.17
5.2.60.0090.0469.12
5.2.50.0090.0329.09
5.2.40.0070.0289.07
5.2.30.0040.0319.05
5.2.20.0060.0289.04
5.2.10.0090.0278.95
5.2.00.0060.0328.81
5.1.60.0060.0308.09
5.1.50.0050.0328.09
5.1.40.0070.0228.07
5.1.30.0040.0298.41
5.1.20.0070.0258.44
5.1.10.0060.0248.16
5.1.00.0060.0238.16
5.0.50.0040.0236.64
5.0.40.0030.0206.51
5.0.30.0030.0326.31
5.0.20.0040.0186.28
5.0.10.0060.0176.27
5.0.00.0020.0326.26
4.4.90.0020.0174.78
4.4.80.0030.0154.75
4.4.70.0040.0154.75
4.4.60.0050.0144.76
4.4.50.0020.0184.77
4.4.40.0030.0254.70
4.4.30.0040.0144.76
4.4.20.0040.0144.84
4.4.10.0010.0174.85
4.4.00.0020.0254.76
4.3.110.0030.0154.67
4.3.100.0020.0164.66
4.3.90.0030.0144.63
4.3.80.0060.0214.59
4.3.70.0030.0144.63
4.3.60.0030.0144.63
4.3.50.0030.0164.62
4.3.40.0030.0244.54
4.3.30.0030.0173.30
4.3.20.0020.0183.27
4.3.10.0010.0213.24
4.3.00.0000.0237.28