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 { $cl1 = static function() { return Question::$answer; }; public function getAnswer($that) { //$getTheAnswer = Closure::bind($this->getPrivate(),$that); $getTheAnswer = Closure::bind($cl1, null, $that); $result = $getTheAnswer($that); return $result; } public function getPrivate($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)
5.4.290.0080.04112.50
5.4.280.0080.04312.39
5.4.270.0140.08412.39
5.4.260.0180.08712.39
5.4.250.0080.06312.39
5.4.240.0130.07612.39
5.4.230.0110.05212.38
5.4.220.0140.05312.39
5.4.210.0090.05612.39
5.4.200.0100.05212.39
5.4.190.0080.05012.38
5.4.180.0110.07712.38
5.4.170.0160.11112.39
5.4.160.0120.07712.39
5.4.150.0240.06212.38
5.4.140.0130.10012.07
5.4.130.0160.08112.05
5.4.120.0070.04012.02
5.4.110.0090.09612.01
5.4.100.0120.05912.02
5.4.90.0130.07112.02
5.4.80.0140.04412.02
5.4.70.0120.04912.01
5.4.60.0100.03912.02
5.4.50.0040.03912.02
5.4.40.0060.03912.00
5.4.30.0080.03712.00
5.4.20.0100.04212.00
5.4.10.0050.04212.00
5.4.00.0050.03811.48
5.3.280.0060.04412.71
5.3.270.0080.05312.72
5.3.260.0100.03712.72
5.3.250.0050.04012.72
5.3.240.0040.04012.72
5.3.230.0050.03912.71
5.3.220.0100.03512.68
5.3.210.0050.04112.68
5.3.200.0080.03612.68
5.3.190.0040.04512.67
5.3.180.0080.05112.67
5.3.170.0040.04012.67
5.3.160.0090.03612.68
5.3.150.0080.03712.67
5.3.140.0090.03712.66
5.3.130.0070.04212.66
5.3.120.0150.05612.66
5.3.110.0140.04912.66
5.3.100.0110.04712.12
5.3.90.0100.04512.10
5.3.80.0070.04412.10
5.3.70.0060.03712.10
5.3.60.0040.04612.08
5.3.50.0080.03912.02
5.3.40.0140.04412.03
5.3.30.0040.04011.98
5.3.20.0070.03711.77
5.3.10.0090.03811.73
5.3.00.0070.03811.71
5.2.170.0090.0469.21
5.2.160.0050.0349.21
5.2.150.0070.0349.22
5.2.140.0040.0359.22
5.2.130.0040.0399.18
5.2.120.0040.0349.18
5.2.110.0080.0359.18
5.2.100.0100.0389.18
5.2.90.0030.0359.18
5.2.80.0070.0339.17
5.2.70.0080.0319.18
5.2.60.0070.0339.13
5.2.50.0060.0329.10
5.2.40.0080.0299.07
5.2.30.0050.0329.05
5.2.20.0030.0339.04
5.2.10.0050.0308.95
5.2.00.0080.0298.81
5.1.60.0060.0258.09
5.1.50.0020.0288.08
5.1.40.0070.0238.07
5.1.30.0030.0298.41
5.1.20.0050.0278.44
5.1.10.0070.0248.16
5.1.00.0050.0278.16
5.0.50.0050.0206.64
5.0.40.0040.0256.51
5.0.30.0070.0416.31
5.0.20.0030.0266.28
5.0.10.0070.0186.26
5.0.00.0090.0386.25
4.4.90.0030.0254.77
4.4.80.0020.0244.76
4.4.70.0060.0204.76
4.4.60.0060.0194.75
4.4.50.0050.0324.77
4.4.40.0050.0344.71
4.4.30.0030.0174.75
4.4.20.0060.0144.84
4.4.10.0050.0174.85
4.4.00.0040.0314.76
4.3.110.0010.0184.67
4.3.100.0020.0164.67
4.3.90.0050.0204.63
4.3.80.0030.0334.58
4.3.70.0040.0174.63
4.3.60.0040.0144.63
4.3.50.0040.0164.63
4.3.40.0040.0254.54
4.3.30.0020.0183.30
4.3.20.0020.0223.28
4.3.10.0020.0203.23
4.3.00.0170.01313.47

preferences:
142.48 ms | 1394 KiB | 7 Q