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 Answer extends Exception { public function getAnswer(Question q) { return q::answer; } } // end editing here new Question($e);
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected 'q' (T_STRING), expecting '&' or variable (T_VARIABLE) in /in/isfQr on line 25
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING, expecting '&' or T_VARIABLE in /in/isfQr on line 25
Process exited with code 255.

preferences:
182.58 ms | 1395 KiB | 67 Q