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 $that->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).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0120.00316.63
8.3.50.0120.00722.05
8.3.40.0130.00418.75
8.3.30.0080.00619.14
8.3.20.0050.00320.24
8.3.10.0000.00823.52
8.3.00.0060.00319.25
8.2.180.0070.00718.41
8.2.170.0100.01022.96
8.2.160.0070.00720.39
8.2.150.0080.01124.18
8.2.140.0080.00024.66
8.2.130.0070.01126.16
8.2.120.0040.00422.12
8.2.110.0060.00322.26
8.2.100.0040.00717.91
8.2.90.0020.00519.17
8.2.80.0030.00517.97
8.2.70.0030.00617.63
8.2.60.0000.00818.04
8.2.50.0050.00318.07
8.2.40.0000.00819.82
8.2.30.0050.00218.15
8.2.20.0040.00417.74
8.2.10.0030.00518.05
8.2.00.0000.01117.74
8.1.280.0120.00325.92
8.1.270.0000.00823.99
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0090.00023.84
8.1.230.0000.01119.16
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0000.00917.25
8.1.190.0060.00317.54
8.1.180.0000.00919.14
8.1.170.0040.00418.71
8.1.160.0040.00422.02
8.1.150.0000.01018.64
8.1.140.0040.00417.47
8.1.130.0050.00317.83
8.1.120.0040.00417.50
8.1.110.0000.00817.50
8.1.100.0000.00917.36
8.1.90.0070.00017.48
8.1.80.0030.00317.36
8.1.70.0000.00817.48
8.1.60.0050.00217.62
8.1.50.0000.00817.40
8.1.40.0050.00317.48
8.1.30.0040.00417.48
8.1.20.0000.00817.59
8.1.10.0000.00717.57
8.1.00.0040.00417.50
8.0.300.0000.00720.80
8.0.290.0050.00217.17
8.0.280.0030.00318.47
8.0.270.0000.00817.15
8.0.260.0030.00317.18
8.0.250.0040.00417.07
8.0.240.0000.00716.92
8.0.230.0030.00316.93
8.0.220.0000.00716.87
8.0.210.0030.00316.96
8.0.200.0000.00616.89
8.0.190.0000.00816.91
8.0.180.0000.00716.97
8.0.170.0000.00817.01
8.0.160.0070.00017.00
8.0.150.0030.00516.86
8.0.140.0000.00816.92
8.0.130.0030.00313.48
8.0.120.0080.00016.95
8.0.110.0000.00716.80
8.0.100.0000.00816.83
8.0.90.0080.00016.88
8.0.80.0130.00716.93
8.0.70.0000.00817.00
8.0.60.0000.00816.96
8.0.50.0000.00717.04
8.0.30.0120.00717.23
8.0.20.0100.01117.40
8.0.10.0000.00717.16
8.0.00.0120.00716.82
7.4.330.0050.00015.00
7.4.320.0070.00016.61
7.4.300.0060.00016.52
7.4.290.0070.00016.65
7.4.280.0070.00016.61
7.4.270.0000.00716.52
7.4.260.0040.00416.64
7.4.250.0000.00716.48
7.4.240.0060.00116.62
7.4.230.0030.00316.72
7.4.220.0150.00316.51
7.4.210.0060.00916.63
7.4.200.0040.00416.60
7.4.190.0030.00316.57
7.4.160.0140.01016.54
7.4.150.0060.01217.40
7.4.140.0120.00517.86
7.4.130.0110.00716.51
7.4.120.0130.01016.71
7.4.110.0040.01316.72
7.4.100.0130.00316.60
7.4.90.0150.00916.64
7.4.80.0090.01219.39
7.4.70.0060.01616.67
7.4.60.0060.01116.35
7.4.50.0040.00416.59
7.4.40.0050.00722.77
7.4.30.0090.00916.48
7.4.00.0070.00715.22
7.3.330.0000.00513.29
7.3.320.0030.00313.18
7.3.310.0000.00816.21
7.3.300.0030.00616.33
7.3.290.0070.00716.38
7.3.280.0080.00816.37
7.3.270.0110.00717.40
7.3.260.0080.00816.33
7.3.250.0120.00916.54
7.3.240.0170.00616.51
7.3.230.0140.00316.55
7.3.210.0090.00916.40
7.3.200.0120.01219.39
7.3.190.0070.01016.54
7.3.180.0160.00016.43
7.3.170.0100.01016.46
7.3.160.0090.01216.36
7.3.120.0070.00714.99
7.3.10.0060.00916.60
7.3.00.0000.01416.71
7.2.330.0090.01216.59
7.2.320.0130.00316.82
7.2.310.0070.01016.79
7.2.300.0060.01016.57
7.2.290.0090.00916.76
7.2.130.0070.00316.96
7.2.120.0030.01016.98
7.2.110.0060.00317.06
7.2.100.0120.00316.84
7.2.90.0030.01216.82
7.2.80.0110.00016.75
7.2.70.0000.01617.11
7.2.60.0080.00516.89
7.2.50.0060.00616.72
7.2.40.0090.00616.86
7.2.30.0030.01017.10
7.2.20.0030.01016.68
7.2.10.0030.01016.90
7.2.00.0050.00718.22
7.1.250.0000.00915.98
7.1.200.0060.00316.06
7.1.100.0000.01718.18
7.1.70.0070.01017.20
7.1.60.0070.01819.46
7.1.50.0100.01316.95
7.1.00.0070.07322.54
7.0.200.0000.00716.58
7.0.140.0000.07322.16
7.0.60.0170.07720.01
7.0.50.0070.08017.86
7.0.40.0030.04320.21
7.0.30.0270.04020.20
7.0.20.0230.08320.33
7.0.10.0100.07320.09
7.0.00.0100.05320.18
5.6.280.0000.07321.13
5.6.210.0100.06020.64
5.6.200.0100.07718.16
5.6.190.0100.04020.47
5.6.180.0270.08020.54
5.6.170.0100.04720.45
5.6.160.0000.04320.61
5.6.150.0070.08018.16
5.6.140.0070.05018.12
5.6.130.0070.05718.18
5.6.120.0000.04321.16
5.6.110.0070.08720.98
5.6.100.0100.08021.12
5.6.90.0170.07721.14
5.6.80.0070.05020.39
5.5.350.0330.06020.48
5.5.340.0170.06718.08
5.5.330.0000.05020.57
5.5.320.0270.04720.35
5.5.310.0300.06320.34
5.5.300.0100.08018.08
5.5.290.0200.07717.94
5.5.280.0070.04320.75
5.5.270.0130.08320.91
5.5.260.0030.04020.81
5.5.250.0100.08320.71
5.5.240.4200.03320.17
5.4.450.0700.06319.48
5.4.440.0670.06019.17
5.4.430.0130.05319.46
5.4.420.0700.06719.46
5.4.410.1030.06019.20
5.4.400.0770.05019.25
5.4.390.0770.05319.30
5.4.380.0330.04718.48
5.4.370.0200.06018.74
5.4.360.0230.05718.71
5.4.350.0230.05718.61
5.4.340.0370.05018.79
5.4.320.0020.04712.52
5.4.310.0050.04212.51
5.4.300.0090.04312.52
5.4.290.0120.05512.50
5.4.280.0120.05412.39
5.4.270.0130.09212.39
5.4.260.0090.04312.39
5.4.250.0090.04612.39
5.4.240.0070.04612.39
5.4.230.0070.04912.38
5.4.220.0050.03912.38
5.4.210.0050.04212.39
5.4.200.0080.05112.38
5.4.190.0090.05412.38
5.4.180.0100.04112.38
5.4.170.0100.06512.39
5.4.160.0080.05812.38
5.4.150.0120.05112.39
5.4.140.0090.04912.07
5.4.130.0090.03612.06
5.4.120.0090.03612.01
5.4.110.0050.04812.01
5.4.100.0070.04212.01
5.4.90.0150.04212.01
5.4.80.0050.04712.01
5.4.70.0050.04512.00
5.4.60.0110.04212.01
5.4.50.0130.04712.00
5.4.40.0140.04911.99
5.4.30.0080.05211.99
5.4.20.0060.05611.99
5.4.10.0070.05211.99
5.4.00.0040.05511.48
5.3.290.0060.04612.80
5.3.280.0130.05512.70
5.3.270.0080.05012.72
5.3.260.0120.05212.72
5.3.250.0080.04612.72
5.3.240.0100.04412.72
5.3.230.0080.04112.71
5.3.220.0080.03812.68
5.3.210.0050.04112.68
5.3.200.0070.03812.68
5.3.190.0080.04612.68
5.3.180.0100.06412.67
5.3.170.0100.05112.67
5.3.160.0070.05412.67
5.3.150.0090.05112.68
5.3.140.0120.05112.66
5.3.130.0140.04712.66
5.3.120.0110.05612.66
5.3.110.0090.05212.66
5.3.100.0150.05512.13
5.3.90.0060.05712.12
5.3.80.0130.04612.11
5.3.70.0100.04812.11
5.3.60.0170.05812.09
5.3.50.0060.04312.04
5.3.40.0050.04312.04
5.3.30.0060.03912.00
5.3.20.0110.03611.79
5.3.10.0090.05111.74
5.3.00.0050.04911.73
5.2.170.0040.0349.23
5.2.160.0060.0419.22
5.2.150.0050.0339.23
5.2.140.0050.0329.22
5.2.130.0040.0399.18
5.2.120.0080.0329.18
5.2.110.0080.0289.19
5.2.100.0060.0339.19
5.2.90.0020.0369.19
5.2.80.0050.0449.18
5.2.70.0050.0449.18
5.2.60.0080.0459.13
5.2.50.0100.0529.10
5.2.40.0090.0379.07
5.2.30.0100.0499.05
5.2.20.0080.0389.04
5.2.10.0080.0408.95
5.2.00.0080.0578.82
5.1.60.0080.0358.09
5.1.50.0080.0328.09
5.1.40.0060.0288.08
5.1.30.0050.0268.43
5.1.20.0060.0258.45
5.1.10.0060.0278.17
5.1.00.0070.0338.17
5.0.50.0060.0266.65
5.0.40.0030.0246.51
5.0.30.0030.0426.32
5.0.20.0040.0366.29
5.0.10.0060.0276.27
5.0.00.0040.0426.26
4.4.90.0040.0244.78
4.4.80.0050.0224.75
4.4.70.0030.0294.75
4.4.60.0060.0194.76
4.4.50.0030.0234.77
4.4.40.0050.0324.71
4.4.30.0040.0184.76
4.4.20.0040.0214.84
4.4.10.0050.0214.85
4.4.00.0060.0314.76
4.3.110.0060.0314.67
4.3.100.0010.0174.66
4.3.90.0040.0214.63
4.3.80.0040.0304.59
4.3.70.0060.0194.63
4.3.60.0030.0204.63
4.3.50.0060.0234.63
4.3.40.0040.0314.53
4.3.30.0030.0193.30
4.3.20.0050.0193.28
4.3.10.0040.0223.23
4.3.00.0270.01710.54

preferences:
41.98 ms | 401 KiB | 5 Q