3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @author Lisachenko Alexander <https://twitter.com/lisachenko> */ class ChuckNorrisException extends Exception { public function __construct($message, array $trace = array(), $code = 0, Exception $previous = null) { parent::__construct($message, 0, $previous); $this->file = 'Real Life'; $setter = function(array $newTrace = array()) { /** @var $this Exception */ $this->trace = $newTrace; }; $setter->bindTo($this, 'Exception')->__invoke($trace); } } throw new ChuckNorrisException("Hello", array( array('file' => 'Chuck Norris, level', 'line' => 99, 'class' => 'own you ', 'function' => 'with uppercut!') ));
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Cannot bind closure to scope of internal class Exception in /in/FTBog on line 15 Fatal error: Uncaught Error: Call to a member function __invoke() on null in /in/FTBog:15 Stack trace: #0 /in/FTBog(19): ChuckNorrisException->__construct('Hello', Array) #1 {main} thrown in /in/FTBog on line 15
Process exited with code 255.
Output for 7.0.18 - 7.0.33, 7.1.4 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Warning: Cannot bind closure to scope of internal class Exception in /in/FTBog on line 15 Fatal error: Uncaught Error: Call to a member function __invoke() on null in /in/FTBog:15 Stack trace: #0 /in/FTBog(20): ChuckNorrisException->__construct('Hello', Array) #1 {main} thrown in /in/FTBog on line 15
Process exited with code 255.
Output for 7.0.0 - 7.0.17, 7.1.0 - 7.1.3
Warning: Cannot bind closure to scope of internal class Exception in /in/FTBog on line 15 Fatal error: Uncaught Error: Call to a member function __invoke() on null in /in/FTBog:15 Stack trace: #0 /in/FTBog(21): ChuckNorrisException->__construct('Hello', Array) #1 {main} thrown in /in/FTBog on line 15
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Uncaught exception 'ChuckNorrisException' with message 'Hello' in Real Life:19 Stack trace: #0 Chuck Norris, level(99): own you with uppercut!() #1 {main} thrown in Real Life on line 19
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Fatal error: Call to undefined method Closure::bindTo() in /in/FTBog on line 15
Process exited with code 255.

preferences:
257.97 ms | 401 KiB | 413 Q