3v4l.org

run code in 300+ PHP versions simultaneously
<?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 () { return $this->answer; }, $that, $that); var_dump($answerTime); var_dump($answerTime($that)); } 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).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0110.00316.63
8.3.50.0380.00521.88
8.3.40.0120.00618.90
8.3.30.0110.00319.14
8.3.20.0040.00420.13
8.3.10.0080.00023.70
8.3.00.0000.00819.38
8.2.180.0070.00718.51
8.2.170.0140.00422.96
8.2.160.0030.01020.53
8.2.150.0080.00024.18
8.2.140.0110.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00422.25
8.2.110.0070.00319.24
8.2.100.0000.01217.72
8.2.90.0000.00819.22
8.2.80.0050.00317.97
8.2.70.0090.00017.63
8.2.60.0040.00418.04
8.2.50.0030.00618.07
8.2.40.0000.00919.88
8.2.30.0000.00718.09
8.2.20.0070.00017.65
8.2.10.0050.00218.09
8.2.00.0030.00617.72
8.1.280.0070.01325.92
8.1.270.0040.00423.96
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0030.00723.96
8.1.230.0090.00320.97
8.1.220.0030.00517.74
8.1.210.0000.00818.77
8.1.200.0030.00617.48
8.1.190.0030.00517.30
8.1.180.0000.00919.01
8.1.170.0040.00418.45
8.1.160.0080.00021.96
8.1.150.0030.00618.58
8.1.140.0040.00417.35
8.1.130.0000.00717.81
8.1.120.0000.00817.50
8.1.110.0000.00817.41
8.1.100.0070.00317.38
8.1.90.0040.00417.48
8.1.80.0030.00317.38
8.1.70.0030.00317.40
8.1.60.0030.00617.67
8.1.50.0000.00817.42
8.1.40.0000.00817.54
8.1.30.0040.00417.61
8.1.20.0060.00317.67
8.1.10.0040.00417.61
8.1.00.0040.00417.61
8.0.300.0060.00320.78
8.0.290.0040.00317.16
8.0.280.0030.00318.47
8.0.270.0030.00317.28
8.0.260.0030.00318.34
8.0.250.0000.00717.07
8.0.240.0040.00416.93
8.0.230.0030.00317.07
8.0.220.0000.00617.02
8.0.210.0000.00716.93
8.0.200.0000.00717.04
8.0.190.0000.00816.95
8.0.180.0040.00416.84
8.0.170.0000.00816.98
8.0.160.0000.00816.93
8.0.150.0000.00716.99
8.0.140.0000.00716.83
8.0.130.0030.00313.45
8.0.120.0080.00017.00
8.0.110.0030.00516.91
8.0.100.0040.00416.94
8.0.90.0040.00416.99
8.0.80.0100.00616.90
8.0.70.0070.00016.88
8.0.60.0040.00416.85
8.0.50.0040.00416.87
8.0.30.0100.01017.16
8.0.20.0090.00917.40
8.0.10.0000.00717.20
8.0.00.0100.00816.96
7.4.330.0050.00015.02
7.4.320.0030.00316.57
7.4.300.0000.00716.38
7.4.290.0040.00416.57
7.4.280.0050.00316.45
7.4.270.0000.00716.64
7.4.260.0000.00716.43
7.4.250.0080.00016.46
7.4.240.0020.00516.62
7.4.230.0040.00416.65
7.4.220.0070.01016.56
7.4.210.0090.00616.61
7.4.200.0040.00416.60
7.4.190.0000.00816.72
7.4.160.0140.00316.57
7.4.150.0090.00917.40
7.4.140.0080.01017.86
7.4.130.0100.00816.50
7.4.120.0090.00716.62
7.4.110.0060.01216.41
7.4.100.0180.00416.61
7.4.90.0130.00316.62
7.4.80.0100.01119.39
7.4.70.0140.00316.60
7.4.60.0110.00616.63
7.4.50.0030.00316.48
7.4.40.0090.00922.77
7.4.30.0150.00316.53
7.4.00.0090.00915.22
7.3.330.0030.00313.34
7.3.320.0000.00513.30
7.3.310.0080.00016.33
7.3.300.0080.00016.34
7.3.290.0070.00716.32
7.3.280.0100.00716.38
7.3.270.0040.01317.40
7.3.260.0090.00916.52
7.3.250.0080.00916.43
7.3.240.0160.00016.51
7.3.230.0030.01316.42
7.3.210.0170.00016.50
7.3.200.0060.01219.39
7.3.190.0140.01116.34
7.3.180.0040.01116.49
7.3.170.0100.00616.35
7.3.160.0060.01016.30
7.3.120.0090.00614.79
7.2.330.0030.01416.81
7.2.320.0060.01216.51
7.2.310.0130.00316.79
7.2.300.0060.01116.73
7.2.290.0130.00316.59
7.2.60.0090.00616.74
7.2.00.0040.00719.44
7.1.200.0090.00615.68
7.1.100.0150.00018.08
7.1.70.0080.00017.04
7.1.60.0110.00719.46
7.1.50.0130.01017.05
7.1.00.0030.07722.25
7.0.200.0030.00316.75
7.0.140.0070.06721.95
7.0.60.0100.07319.99
7.0.50.0030.04017.84
7.0.40.0100.08020.05
7.0.30.0330.06720.06
7.0.20.0200.04320.09
7.0.10.0030.06320.16
7.0.00.0130.07720.09
5.6.280.0000.07720.91
5.6.210.0170.05720.53
5.6.200.0070.08318.13
5.6.190.0170.07320.73
5.6.180.0270.06720.60
5.6.170.0330.06320.56
5.6.160.0170.07320.54
5.6.150.0000.04018.27
5.6.140.0070.08018.21
5.6.130.0030.08018.26
5.6.120.0100.07721.02
5.6.110.0070.03721.06
5.6.100.0030.08020.99
5.6.90.0030.04321.00
5.6.80.0070.08320.41
5.6.70.4300.03320.41
5.5.350.0300.07720.39
5.5.340.0130.07018.00
5.5.330.0100.04720.37
5.5.320.0300.03720.38
5.5.310.0270.06720.30
5.5.300.0170.04018.08
5.5.290.0030.08717.98
5.5.280.0030.08720.91
5.5.270.0200.07020.74
5.5.260.0100.07720.66
5.5.250.0070.08020.50
5.5.240.3430.03020.17
5.4.450.0900.08719.60
5.4.440.0800.06719.55
5.4.430.0170.05319.47
5.4.420.0100.05719.44
5.4.410.0770.06019.40
5.4.400.0600.05719.05
5.4.390.0670.05718.97
5.4.380.0330.05718.60
5.4.370.0630.04718.58
5.4.360.0370.05318.49
5.4.350.0730.06018.76
5.4.340.0300.05318.79
5.4.320.0080.03812.52
5.4.310.0100.03612.52
5.4.300.0060.04712.52
5.4.290.0110.06512.49
5.4.280.0070.04412.39
5.4.270.0070.04412.39
5.4.260.0080.05812.39
5.4.250.0090.05212.39
5.4.240.0080.05212.39
5.4.230.0090.05012.38
5.4.220.0130.06612.39
5.4.210.0100.05312.38
5.4.200.0090.05412.38
5.4.190.0090.05312.38
5.4.180.0100.06712.38
5.4.170.0090.05812.39
5.4.160.0080.05712.39
5.4.150.0110.06312.38
5.4.140.0080.05112.07
5.4.130.0120.04412.05
5.4.120.0140.07912.01
5.4.110.0120.07512.01
5.4.100.0090.06812.01
5.4.90.0100.04112.01
5.4.80.0140.04712.01
5.4.70.0070.05612.01
5.4.60.0120.10312.00
5.4.50.0550.18112.00
5.4.40.0100.07412.00
5.4.30.0050.06411.99
5.4.20.0200.06411.99
5.4.10.0100.04611.99
5.4.00.0040.04411.48
5.3.290.0100.04212.80
5.3.280.0070.05112.70
5.3.270.0170.06712.72
5.3.260.0050.05212.71
5.3.250.0100.03912.72
5.3.240.0050.04312.72
5.3.230.0090.03812.71
5.3.220.0090.05612.68
5.3.210.0160.05112.68
5.3.200.0060.04312.68
5.3.190.0080.04112.68
5.3.180.0090.04912.67
5.3.170.0080.04812.67
5.3.160.0200.05712.67
5.3.150.0100.04712.67
5.3.140.0100.04112.66
5.3.130.0080.04012.66
5.3.120.0080.03912.66
5.3.110.0090.03912.66
5.3.100.0080.04612.13
5.3.90.0070.03912.11
5.3.80.0100.03812.11
5.3.70.0100.04712.11
5.3.60.0080.04912.09
5.3.50.0090.03612.04
5.3.40.0090.03512.04
5.3.30.0120.05012.00
5.3.20.0080.03511.78
5.3.10.0070.03811.74
5.3.00.0100.04811.73
5.2.170.0040.0389.22
5.2.160.0040.0329.22
5.2.150.0100.0439.23
5.2.140.0080.0379.21
5.2.130.0030.0359.18
5.2.120.0050.0329.18
5.2.110.0050.0309.19
5.2.100.0090.0379.19
5.2.90.0070.0409.19
5.2.80.0110.0359.18
5.2.70.0180.0469.19
5.2.60.0110.0529.13
5.2.50.0080.0439.10
5.2.40.0130.0349.07
5.2.30.0090.0419.06
5.2.20.0060.0409.04
5.2.10.0070.0428.95
5.2.00.0100.0488.82
5.1.60.0110.0588.09
5.1.50.0060.0328.09
5.1.40.0070.0258.07
5.1.30.0060.0298.42
5.1.20.0080.0628.44
5.1.10.0060.0268.17
5.1.00.0080.0378.17
5.0.50.0110.0286.66
5.0.40.0030.0226.50
5.0.30.0010.0376.32
5.0.20.0060.0376.28
5.0.10.0090.0486.27
5.0.00.0020.0386.26
4.4.90.0040.0174.78
4.4.80.0040.0164.75
4.4.70.0030.0184.76
4.4.60.0030.0194.75
4.4.50.0060.0174.77
4.4.40.0030.0294.71
4.4.30.0060.0184.75
4.4.20.0040.0194.84
4.4.10.0050.0154.85
4.4.00.0050.0254.76
4.3.110.0030.0184.67
4.3.100.0030.0194.66
4.3.90.0020.0174.63
4.3.80.0040.0254.58
4.3.70.0040.0144.63
4.3.60.0030.0224.63
4.3.50.0040.0224.63
4.3.40.0030.0334.54
4.3.30.0060.0253.30
4.3.20.0030.0323.28
4.3.10.0020.0233.23
4.3.00.0100.01710.54

preferences:
47.16 ms | 401 KiB | 5 Q