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 function getAnswer($that) { // Closure::bind() actually creates a new instance of the closure $answerTime = Closure::bind($this->getAnswer2, null, $that); var_dump($answerTime); } public function getAnswer($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.04012.50
5.4.280.0050.03612.39
5.4.270.0050.03712.39
5.4.260.0090.04412.39
5.4.250.0060.05212.39
5.4.240.0080.03612.39
5.4.230.0050.03912.38
5.4.220.0020.04012.38
5.4.210.0070.03412.39
5.4.200.0060.03812.39
5.4.190.0070.03612.38
5.4.180.0080.04012.38
5.4.170.0060.03612.39
5.4.160.0080.03612.39
5.4.150.0080.04212.39
5.4.140.0040.04812.07
5.4.130.0070.04312.06
5.4.120.0060.05212.02
5.4.110.0100.04912.01
5.4.100.0070.03812.02
5.4.90.0020.04212.01
5.4.80.0080.03712.01
5.4.70.0090.03512.01
5.4.60.0090.03512.01
5.4.50.0080.03912.01
5.4.40.0060.04611.99
5.4.30.0140.09911.99
5.4.20.0040.04211.99
5.4.10.0100.03412.00
5.4.00.0070.04011.48
5.3.280.0090.04212.71
5.3.270.0090.05412.72
5.3.260.0070.05612.72
5.3.250.0120.08012.72
5.3.240.0070.05612.72
5.3.230.0050.04312.71
5.3.220.0100.04112.68
5.3.210.0050.04112.68
5.3.200.0040.04612.68
5.3.190.0080.05912.67
5.3.180.0120.04212.68
5.3.170.0090.03712.67
5.3.160.0080.03612.68
5.3.150.0060.04012.67
5.3.140.0090.03612.66
5.3.130.0080.03812.66
5.3.120.0090.04012.66
5.3.110.0060.04212.66
5.3.100.0060.03812.13
5.3.90.0040.04112.11
5.3.80.0060.04012.10
5.3.70.0030.04112.10
5.3.60.0070.03912.09
5.3.50.0130.04412.03
5.3.40.0090.03812.03
5.3.30.0050.04712.00
5.3.20.0060.04211.77
5.3.10.0070.04011.74
5.3.00.0070.04511.72

preferences:
139.38 ms | 1386 KiB | 7 Q