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; }, null, $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.0070.00716.63
8.3.50.0190.01122.06
8.3.40.0100.00718.89
8.3.30.0070.00719.27
8.3.20.0040.00420.09
8.3.10.0030.00523.66
8.3.00.0050.00319.25
8.2.180.0100.00718.41
8.2.170.0100.01022.96
8.2.160.0030.01020.35
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0180.00026.16
8.2.120.0070.00022.25
8.2.110.0050.00521.19
8.2.100.0040.00818.03
8.2.90.0040.00418.03
8.2.80.0000.00817.97
8.2.70.0070.00417.50
8.2.60.0050.00317.64
8.2.50.0060.00318.07
8.2.40.0000.00819.88
8.2.30.0040.00418.00
8.2.20.0050.00317.76
8.2.10.0040.00418.13
8.2.00.0040.00717.66
8.1.280.0070.01125.92
8.1.270.0060.00323.84
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0090.00321.99
8.1.230.0050.00520.97
8.1.220.0050.00317.74
8.1.210.0030.00618.93
8.1.200.0060.00317.35
8.1.190.0040.00417.40
8.1.180.0060.00318.10
8.1.170.0090.00018.64
8.1.160.0000.00821.95
8.1.150.0030.00618.60
8.1.140.0000.00717.43
8.1.130.0070.00017.88
8.1.120.0000.00717.51
8.1.110.0000.00817.52
8.1.100.0000.00917.37
8.1.90.0040.00417.50
8.1.80.0030.00317.39
8.1.70.0070.00017.46
8.1.60.0040.00417.63
8.1.50.0040.00417.52
8.1.40.0040.00417.50
8.1.30.0040.00417.64
8.1.20.0030.00517.69
8.1.10.0000.00817.58
8.1.00.0040.00417.49
8.0.300.0000.00919.89
8.0.290.0000.00717.28
8.0.280.0030.00318.50
8.0.270.0030.00317.28
8.0.260.0050.00317.19
8.0.250.0000.00717.10
8.0.240.0000.00716.90
8.0.230.0030.00317.04
8.0.220.0000.00716.88
8.0.210.0030.00317.04
8.0.200.0030.00316.91
8.0.190.0050.00316.99
8.0.180.0030.00516.94
8.0.170.0040.00416.89
8.0.160.0040.00416.97
8.0.150.0050.00317.04
8.0.140.0030.00316.97
8.0.130.0060.00013.38
8.0.120.0040.00416.90
8.0.110.0000.00716.88
8.0.100.0040.00417.03
8.0.90.0000.00716.87
8.0.80.0070.01416.90
8.0.70.0000.00716.85
8.0.60.0040.00416.86
8.0.50.0040.00416.84
8.0.30.0130.00817.12
8.0.20.0090.01117.40
8.0.10.0050.00217.15
8.0.00.0140.00316.89
7.4.330.0000.00615.00
7.4.320.0060.00016.57
7.4.300.0060.00016.59
7.4.290.0070.00016.63
7.4.280.0040.00316.60
7.4.270.0000.00716.52
7.4.260.0070.00016.40
7.4.250.0000.00816.58
7.4.240.0010.00616.61
7.4.230.0030.00316.36
7.4.220.0100.00716.64
7.4.210.0090.00916.57
7.4.200.0000.00916.35
7.4.190.0070.00016.38
7.4.160.0060.01216.37
7.4.150.0090.00917.40
7.4.140.0070.01017.86
7.4.130.0070.01216.59
7.4.120.0070.01016.54
7.4.110.0120.00616.50
7.4.100.0120.00916.54
7.4.90.0030.01416.75
7.4.80.0100.00719.39
7.4.70.0130.00616.60
7.4.60.0060.01016.71
7.4.50.0060.00316.31
7.4.40.0090.00622.77
7.4.30.0120.00616.33
7.4.00.0100.00615.24
7.3.330.0000.00613.37
7.3.320.0000.00613.21
7.3.310.0070.00016.32
7.3.300.0070.00016.36
7.3.290.0090.00916.38
7.3.280.0060.01116.36
7.3.270.0100.00717.40
7.3.260.0080.00916.49
7.3.250.0100.00716.46
7.3.240.0170.00016.43
7.3.230.0140.00416.53
7.3.210.0120.00616.56
7.3.200.0100.01019.39
7.3.190.0060.01116.49
7.3.180.0060.00916.48
7.3.170.0090.00616.47
7.3.160.0060.00916.63
7.3.120.0130.00314.63
7.2.330.0000.01616.46
7.2.320.0070.01016.49
7.2.310.0040.01316.80
7.2.300.0070.01016.70
7.2.290.0070.01016.77
7.2.00.0000.01219.36
7.1.100.0070.00718.03
7.1.70.0000.01416.87
7.1.60.0070.01719.46
7.1.50.0090.00616.93
7.1.00.0000.08022.27
7.0.200.0040.00416.62
7.0.140.0000.07721.95
7.0.60.0100.08019.79
7.0.50.0000.04317.96
7.0.40.0070.09020.02
7.0.30.0230.06020.19
7.0.20.0430.07720.23
7.0.10.0070.09020.05
7.0.00.0100.07020.23
5.6.280.0030.07320.79
5.6.210.0070.06320.70
5.6.200.0030.08018.16
5.6.190.0130.05320.64
5.6.180.0330.07320.41
5.6.170.0400.04020.55
5.6.160.0100.08020.70
5.6.150.0000.08718.19
5.6.140.0200.07318.20
5.6.130.0100.08018.12
5.6.120.0070.04020.91
5.6.110.0030.09321.01
5.6.100.0000.07021.16
5.6.90.0100.06320.99
5.6.80.0100.06320.41
5.5.350.4200.04320.45
5.5.340.0070.08018.05
5.5.330.0100.08020.43
5.5.320.0130.04720.51
5.5.310.0300.06320.31
5.5.300.0100.04717.98
5.5.290.0100.03317.93
5.5.280.0030.07020.83
5.5.270.0130.07720.98
5.5.260.0070.08320.89
5.5.250.0130.06020.48
5.5.240.0230.07020.09
5.4.450.0530.04719.48
5.4.440.0470.06019.38
5.4.430.0330.05019.48
5.4.420.0330.04719.51
5.4.410.0570.04019.14
5.4.400.0430.06318.95
5.4.390.0370.03719.06
5.4.380.0430.06719.15
5.4.370.0430.05019.15
5.4.360.0370.05019.14
5.4.350.0570.05719.22
5.4.340.0500.06719.17
5.4.320.0500.05019.23
5.4.310.0430.04719.08
5.4.300.0570.05718.84
5.4.290.0370.04319.21
5.4.280.0570.06319.19
5.4.270.0530.06319.23
5.4.260.0670.07318.87
5.4.250.0730.02719.05
5.4.240.0470.07018.86
5.4.230.0530.05319.18
5.4.220.0430.04719.08
5.4.210.0530.06019.25
5.4.200.0430.04719.22
5.4.190.0500.04718.86
5.4.180.0400.04019.15
5.4.170.0500.06319.15
5.4.160.0530.05319.07
5.4.150.0530.06319.14
5.4.140.0570.05016.41
5.4.130.0570.06016.71
5.4.120.0500.06016.56
5.4.110.0430.03316.56
5.4.100.0370.04016.45
5.4.90.0500.06716.32
5.4.80.0430.04716.22
5.4.70.0470.03016.59
5.4.60.0470.06716.45
5.4.50.0400.03316.52
5.4.40.0430.03716.51
5.4.30.0500.06016.52
5.4.20.0430.04016.48
5.4.10.0500.04716.47
5.4.00.0500.04315.80
5.3.290.0500.06714.65
5.3.280.0370.04014.83
5.3.270.0400.04014.84
5.3.260.0530.06714.69
5.3.250.0500.06714.63
5.3.240.0470.06014.53
5.3.230.0530.05714.59
5.3.220.0570.05314.63
5.3.210.0370.06714.55
5.3.200.0500.06714.50
5.3.190.0570.05314.50
5.3.180.0570.05714.70
5.3.170.0530.06014.54
5.3.160.0500.06014.48
5.3.150.0500.06014.53
5.3.140.0330.04014.67
5.3.130.0400.03714.67
5.3.120.0430.03314.53
5.3.110.0430.05314.55
5.3.100.0470.06313.96
5.3.90.0470.04713.93
5.3.80.0470.06714.14
5.3.70.0470.05013.95
5.3.60.0600.06313.94
5.3.50.0500.06313.89
5.3.40.0570.06314.01
5.3.30.0570.05313.99
5.3.20.0530.04013.62
5.3.10.0570.05313.83
5.3.00.0470.03013.68
5.2.170.0400.05011.07
5.2.160.0330.03311.37
5.2.150.0430.05011.37
5.2.140.0400.05711.13
5.2.130.0370.05711.12
5.2.120.0430.05711.02
5.2.110.0430.05011.27
5.2.100.0330.05011.06
5.2.90.0370.03011.04
5.2.80.0400.04011.02
5.2.70.0430.05711.02
5.2.60.0370.04010.96
5.2.50.0430.04710.94
5.2.40.0330.05311.21
5.2.30.0330.04011.05
5.2.20.0370.04711.04
5.2.10.0400.05011.02
5.2.00.0400.05010.77
5.1.60.0270.0409.93
5.1.50.0370.0479.90
5.1.40.0370.04310.07
5.1.30.0300.04010.56
5.1.20.0370.04710.52
5.1.10.0330.05010.13
5.1.00.0270.03710.15
5.0.50.0200.0378.71
5.0.40.0300.0238.53
5.0.30.0200.0508.54
5.0.20.0200.0308.55
5.0.10.0170.0278.55
5.0.00.0130.0578.55
4.4.90.0270.0238.45
4.4.80.0170.0338.45
4.4.70.0200.0308.45
4.4.60.0200.0178.45
4.4.50.0200.0178.45
4.4.40.0170.0308.47
4.4.30.0230.0208.48
4.4.20.0200.0308.48
4.4.10.0130.0278.51
4.4.00.0200.0438.52
4.3.110.0270.0178.54
4.3.100.0200.0338.54
4.3.90.0170.0338.55
4.3.80.0200.0408.55
4.3.70.0200.0178.55
4.3.60.0200.0308.56
4.3.50.0170.0308.57
4.3.40.0200.0338.59
4.3.30.0070.0208.59
4.3.20.0070.0278.59
4.3.10.0100.0338.59
4.3.00.0070.0238.61

preferences:
41.05 ms | 401 KiB | 5 Q