3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* Challenge 3: Use reflection to get access to Question::$answer from $e->getAnswer */ class Question { private $answer = 42; public function __construct($e) { try { throw $e; } catch (Exception $e) { echo $e->getAnswer($this) . PHP_EOL; } } } // start editing here class exceptionFun extends Exception { public $that; public function getAnswer($that) { /* $this->that = $that; $answerTime = Closure::bind($this->getPrivate(), null, $that); var_dump($answerTime); */ //$this->that = $that; $answerTime = Closure::bind(function ($that) { return $this->answer; }, $that, $that); var_dump($answerTime); } public function getPrivate() { $that = $this->that; return $that->answer; } } $e = new exceptionFun(); // end editing here new Question($e);

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.2.00.0160.00019.51
7.1.100.0030.01317.85
7.1.70.0040.00417.02
7.1.60.0100.01319.46
7.1.50.0000.02317.06
7.1.00.0100.07022.36
7.0.200.0050.00216.75
7.0.140.0000.07322.01
7.0.60.0100.07720.08
7.0.50.0030.05017.85
7.0.40.0030.04719.96
7.0.30.0270.05020.15
7.0.20.0230.08020.10
7.0.10.0000.06020.30
7.0.00.0070.04020.11
5.6.280.0000.07721.14
5.6.210.0070.06320.56
5.6.200.0070.08318.16
5.6.190.0030.07720.54
5.6.180.0300.07320.51
5.6.170.0270.07720.40
5.6.160.0170.07020.48
5.6.150.0030.07018.27
5.6.140.0070.05018.18
5.6.130.0030.04718.19
5.6.120.0070.09020.97
5.6.110.0070.09320.97
5.6.100.0100.07320.99
5.6.90.0130.06320.97
5.6.80.0100.07720.49
5.6.70.4300.03320.48
5.5.350.0200.08020.30
5.5.340.0070.08718.05
5.5.330.0030.04320.26
5.5.320.0130.05020.27
5.5.310.0330.08020.34
5.5.300.0030.05717.99
5.5.290.0130.07717.97
5.5.280.0070.05720.86
5.5.270.0130.06020.70
5.5.260.0030.04020.81
5.5.250.0030.08720.63
5.5.240.2270.04320.30
5.4.450.0700.05319.65
5.4.440.1230.06319.52
5.4.430.0770.05019.43
5.4.420.1100.06019.36
5.4.410.0700.05319.34
5.4.400.0700.05019.14
5.4.390.0100.05319.25
5.4.380.0470.07018.59
5.4.370.0200.05718.79
5.4.360.0230.05718.49
5.4.350.0470.06718.71
5.4.340.0470.06018.61
5.4.320.0020.04112.52
5.4.310.0050.04212.51
5.4.300.0050.04112.52
5.4.290.0110.04112.49
5.4.280.0080.04012.39
5.4.270.0120.06912.39
5.4.260.0090.06712.39
5.4.250.0090.05312.39
5.4.240.0080.06012.39
5.4.230.0120.09612.38
5.4.220.0070.05312.38
5.4.210.0090.05212.38
5.4.200.0090.06312.38
5.4.190.0080.07312.38
5.4.180.0110.08312.38
5.4.170.0090.05512.39
5.4.160.0080.04412.38
5.4.150.0150.05212.38
5.4.140.0070.04312.07
5.4.130.0130.06012.05
5.4.120.0140.06212.02
5.4.110.0050.04312.00
5.4.100.0090.04012.01
5.4.90.0080.04512.01
5.4.80.0140.06912.01
5.4.70.0070.06012.00
5.4.60.0060.06412.00
5.4.50.0100.05112.01
5.4.40.0070.04511.99
5.4.30.0080.05211.99
5.4.20.0080.05311.99
5.4.10.0100.06211.99
5.4.00.0090.08011.48
5.3.290.0080.03912.80
5.3.280.0140.06812.71
5.3.270.0140.05112.73
5.3.260.0060.05812.72
5.3.250.0040.04612.72
5.3.240.0080.06212.72
5.3.230.0100.05212.71
5.3.220.0080.04812.68
5.3.210.0070.04312.68
5.3.200.0070.05112.68
5.3.190.0090.05312.68
5.3.180.0200.08712.67
5.3.170.0140.06712.67
5.3.160.0130.08912.68
5.3.150.0110.09012.67
5.3.140.0120.08412.66
5.3.130.0200.08012.66
5.3.120.0090.05612.66
5.3.110.0090.05812.66
5.3.100.0050.04712.13
5.3.90.0100.04312.12
5.3.80.0060.04512.11
5.3.70.0080.04312.11
5.3.60.0090.04512.09
5.3.50.0060.04412.04
5.3.40.0090.05412.04
5.3.30.0090.04312.00
5.3.20.0110.08211.79
5.3.10.0190.07411.75
5.3.00.0150.09611.74
5.2.170.0160.0569.22
5.2.160.0120.0679.23
5.2.150.0140.0749.23
5.2.140.0210.0569.22
5.2.130.0110.0739.18
5.2.120.0110.0509.18
5.2.110.0170.0599.19
5.2.100.0200.0789.19
5.2.90.0140.0709.19
5.2.80.0130.0599.18
5.2.70.0180.0609.18
5.2.60.0170.0799.13
5.2.50.0060.0449.11
5.2.40.0160.0819.07
5.2.30.0160.0939.06
5.2.20.0120.0589.04
5.2.10.0150.0448.95
5.2.00.0140.0808.81
5.1.60.0090.0638.09
5.1.50.0060.0468.09
5.1.40.0070.0268.08
5.1.30.0060.0298.42
5.1.20.0090.0278.45
5.1.10.0050.0368.17
5.1.00.0040.0308.17
5.0.50.0060.0246.65
5.0.40.0110.0366.51
5.0.30.0060.0376.32
5.0.20.0060.0376.29
5.0.10.0070.0366.27
5.0.00.0060.0346.26
4.4.90.0030.0184.77
4.4.80.0030.0174.75
4.4.70.0020.0194.75
4.4.60.0030.0194.75
4.4.50.0020.0184.77
4.4.40.0060.0264.71
4.4.30.0060.0164.76
4.4.20.0040.0184.85
4.4.10.0060.0164.85
4.4.00.0040.0344.75
4.3.110.0060.0174.67
4.3.100.0030.0164.67
4.3.90.0020.0174.64
4.3.80.0020.0284.58
4.3.70.0030.0174.63
4.3.60.0030.0154.63
4.3.50.0020.0184.63
4.3.40.0040.0254.53
4.3.30.0040.0153.30
4.3.20.0020.0183.28
4.3.10.0020.0183.24
4.3.00.0270.03310.54