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); */ $lambda = new ReflectionFunction($that->answer); var_dump($lambda->invoke()); } 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.70.0040.01118.27
8.3.60.0110.00416.61
8.3.50.0170.01122.03
8.3.40.0140.00418.79
8.3.30.0030.01019.23
8.3.20.0000.00720.06
8.3.10.0000.00823.63
8.3.00.0040.00419.38
8.2.180.0090.00918.54
8.2.170.0140.00722.96
8.2.160.0140.00020.57
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0070.00026.16
8.2.120.0040.00422.11
8.2.110.0070.00422.08
8.2.100.0120.00017.69
8.2.90.0050.00319.16
8.2.80.0080.00017.97
8.2.70.0080.00017.38
8.2.60.0070.00317.86
8.2.50.0060.00318.07
8.2.40.0030.00620.01
8.2.30.0040.00418.07
8.2.20.0080.00017.81
8.2.10.0070.00018.00
8.2.00.0000.01117.78
8.1.280.0100.00725.92
8.1.270.0030.00623.84
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0030.00620.91
8.1.230.0070.00419.07
8.1.220.0030.00617.74
8.1.210.0030.00518.77
8.1.200.0030.00617.22
8.1.190.0000.00717.53
8.1.180.0000.01018.10
8.1.170.0030.00618.65
8.1.160.0000.00721.99
8.1.150.0070.00418.70
8.1.140.0000.00817.48
8.1.130.0000.00817.44
8.1.120.0040.00417.39
8.1.110.0000.00717.50
8.1.100.0100.00017.38
8.1.90.0040.00417.52
8.1.80.0000.00717.40
8.1.70.0000.00717.36
8.1.60.0080.00017.57
8.1.50.0030.00617.55
8.1.40.0080.00017.54
8.1.30.0000.00817.68
8.1.20.0000.00717.75
8.1.10.0050.00317.47
8.1.00.0000.00717.50
8.0.300.0000.00719.21
8.0.290.0040.00417.18
8.0.280.0020.00518.44
8.0.270.0030.00317.22
8.0.260.0040.00416.91
8.0.250.0040.00416.85
8.0.240.0000.00716.90
8.0.230.0000.00716.88
8.0.220.0070.00016.95
8.0.210.0030.00316.89
8.0.200.0000.00617.02
8.0.190.0030.00616.95
8.0.180.0000.00816.83
8.0.170.0000.00716.85
8.0.160.0000.00716.77
8.0.150.0020.00516.81
8.0.140.0030.00316.93
8.0.130.0000.00613.40
8.0.120.0000.00716.94
8.0.110.0000.00816.87
8.0.100.0080.00016.97
8.0.90.0030.00517.04
8.0.80.0160.00317.03
8.0.70.0000.00816.85
8.0.60.0000.00716.89
8.0.50.0040.00417.02
8.0.30.0090.01217.33
8.0.20.0080.01017.40
8.0.10.0040.00416.92
8.0.00.0100.00817.01
7.4.330.0000.00515.00
7.4.320.0030.00316.48
7.4.300.0040.00416.66
7.4.290.0000.00716.53
7.4.280.0000.00716.52
7.4.270.0040.00416.44
7.4.260.0000.00716.50
7.4.250.0080.00016.63
7.4.240.0030.00416.58
7.4.230.0040.00416.42
7.4.220.0130.00716.63
7.4.210.0060.00816.60
7.4.200.0000.00816.65
7.4.190.0030.00316.58
7.4.160.0080.00816.35
7.4.150.0120.00817.40
7.4.140.0120.00417.86
7.4.130.0070.00916.52
7.4.120.0120.00816.62
7.4.110.0130.00616.57
7.4.100.0030.01416.62
7.4.90.0060.01116.68
7.4.80.0160.00619.39
7.4.70.0170.00016.46
7.4.60.0030.01316.50
7.4.50.0000.00616.36
7.4.40.0030.00822.77
7.4.30.0130.00316.50
7.4.00.0150.00014.97
7.3.330.0000.00713.25
7.3.320.0050.00013.37
7.3.310.0050.00316.46
7.3.300.0030.00616.39
7.3.290.0070.00716.45
7.3.280.0100.00616.45
7.3.270.0060.01217.40
7.3.260.0130.00416.50
7.3.250.0110.00616.44
7.3.240.0060.01116.48
7.3.230.0090.00916.54
7.3.210.0090.00916.48
7.3.200.0130.01019.39
7.3.190.0080.01316.48
7.3.180.0090.00616.39
7.3.170.0100.00716.36
7.3.160.0100.00716.48
7.3.120.0090.00615.10
7.3.10.0030.00916.60
7.3.00.0000.01316.73
7.2.330.0060.01016.83
7.2.320.0100.00716.82
7.2.310.0090.00716.71
7.2.300.0100.00716.41
7.2.290.0040.01216.76
7.2.130.0040.01416.89
7.2.120.0040.00416.91
7.2.110.0080.00316.89
7.2.100.0040.00716.84
7.2.90.0060.00616.65
7.2.80.0030.01416.92
7.2.70.0000.01416.97
7.2.60.0100.00116.79
7.2.50.0030.00716.84
7.2.40.0100.00316.98
7.2.30.0060.00916.96
7.2.20.0000.00917.08
7.2.10.0060.00616.71
7.2.00.0040.00618.08
7.1.250.0090.00615.68
7.1.200.0040.01115.60
7.1.100.0000.01118.20
7.1.70.0040.00417.15
7.1.60.0070.01719.46
7.1.50.0120.01217.02
7.1.00.0070.07322.46
7.0.200.0000.01016.73
7.0.140.0030.07322.18
7.0.60.0000.04319.98
7.0.50.0030.08017.89
7.0.40.0100.07320.18
7.0.30.0170.04020.34
7.0.20.0430.06720.23
7.0.10.0070.04020.23
7.0.00.0100.05720.32
5.6.280.0100.06720.86
5.6.210.0070.04020.75
5.6.200.0170.06318.13
5.6.190.0100.08720.62
5.6.180.0370.03720.48
5.6.170.0330.07020.39
5.6.160.0100.04020.51
5.6.150.0130.03718.19
5.6.140.0070.08718.15
5.6.130.0030.05718.18
5.6.120.0070.08721.00
5.6.110.0100.07321.01
5.6.100.0030.04021.12
5.6.90.0100.08321.01
5.6.80.0030.04020.41
5.6.70.4270.03720.37
5.5.350.0270.07020.51
5.5.340.0030.06718.04
5.5.330.0070.06320.22
5.5.320.0400.07020.29
5.5.310.0270.07720.27
5.5.300.0070.03317.97
5.5.290.0130.08017.94
5.5.280.0100.06021.00
5.5.270.0130.08020.88
5.5.260.0130.07720.94
5.5.250.0030.09020.56
5.5.240.3430.02720.36
5.4.450.0230.06719.46
5.4.440.0300.07319.46
5.4.430.0330.07019.54
5.4.420.0270.08319.54
5.4.410.0500.04319.29
5.4.400.0270.07719.20
5.4.390.0430.04319.22
5.4.380.0200.07019.16
5.4.370.0270.04018.99
5.4.360.0230.03719.32
5.4.350.0230.03318.96
5.4.340.0270.03719.10
5.4.320.0170.04019.21
5.4.310.0230.03018.98
5.4.300.0230.03318.98
5.4.290.0230.03719.09
5.4.280.0270.03719.31
5.4.270.0170.04319.20
5.4.260.0170.03719.22
5.4.250.0130.04018.95
5.4.240.0230.03718.94
5.4.230.0200.04018.94
5.4.220.0200.04019.05
5.4.210.0300.02718.86
5.4.200.0270.03318.84
5.4.190.0200.03319.08
5.4.180.0170.03719.07
5.4.170.0170.03719.21
5.4.160.0230.03019.29
5.4.150.0170.03719.07
5.4.140.0200.03316.57
5.4.130.0200.03316.40
5.4.120.0230.03316.38
5.4.110.0430.05016.60
5.4.100.0300.05716.42
5.4.90.0370.05716.50
5.4.80.0230.07316.31
5.4.70.0330.06016.31
5.4.60.0230.06016.43
5.4.50.0300.07016.43
5.4.40.0330.06316.51
5.4.30.0300.06316.52
5.4.20.0330.05016.34
5.4.10.0300.05316.39
5.4.00.0170.05015.84
5.3.290.0170.03714.68
5.3.280.0230.03314.69
5.3.270.0200.03314.77
5.3.260.0200.03714.66
5.3.250.0170.03714.73
5.3.240.0130.04014.53
5.3.230.0170.03714.61
5.3.220.0300.04314.45
5.3.210.0170.05714.49
5.3.200.0370.03714.57
5.3.190.0300.04714.68
5.3.180.0230.07314.73
5.3.170.0370.06314.50
5.3.160.0300.07014.59
5.3.150.0430.04714.63
5.3.140.0270.03714.55
5.3.130.0300.06014.71
5.3.120.0300.07014.61
5.3.110.0330.04714.54
5.3.100.0200.08013.97
5.3.90.0370.06313.95
5.3.80.0330.04714.03
5.3.70.0270.07714.25
5.3.60.0230.07313.91
5.3.50.0370.06013.87
5.3.40.0300.06314.05
5.3.30.0270.04313.97
5.3.20.0370.06713.71
5.3.10.0300.04713.68
5.3.00.0330.06313.77
5.2.170.0170.05712.06
5.2.160.0200.04012.06
5.2.150.0230.03312.06
5.2.140.0300.03312.06
5.2.130.0200.04312.06
5.2.120.0270.05012.06
5.2.110.0270.05012.06
5.2.100.0230.05712.06
5.2.90.0430.04312.06
5.2.80.0170.05712.06
5.2.70.0230.04712.06
5.2.60.0300.04712.06
5.2.50.0630.02712.06
5.2.40.0270.04312.06
5.2.30.0200.05312.06
5.2.20.0270.03712.06
5.2.10.0230.05712.06
5.2.00.0270.02712.06
5.1.60.0200.05012.06
5.1.50.0170.04312.06
5.1.40.0300.03012.06
5.1.30.0200.05312.06
5.1.20.0130.03312.06
5.1.10.0230.04712.06
5.1.00.0230.04712.06
5.0.50.0100.04312.06
5.0.40.0070.04312.06
5.0.30.0170.05712.06
5.0.20.0170.04712.06
5.0.10.0130.04312.06
5.0.00.0130.04712.06
4.4.90.0030.04012.06
4.4.80.0130.03012.06
4.4.70.0100.02712.06
4.4.60.0030.02312.06
4.4.50.0130.03312.06
4.4.40.0100.03312.06
4.4.30.0200.02312.06
4.4.20.0100.04312.06
4.4.10.0170.03312.06
4.4.00.0070.04012.06
4.3.110.0100.02712.06
4.3.100.0130.03312.06
4.3.90.0130.02712.06
4.3.80.0230.02012.06
4.3.70.0070.03712.06
4.3.60.0130.03012.06
4.3.50.0130.02712.06
4.3.40.0100.04012.06
4.3.30.0100.02012.06
4.3.20.0070.01712.06
4.3.10.0070.02012.06
4.3.00.0030.03012.06

preferences:
55.82 ms | 401 KiB | 5 Q