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; var_dump($this); }; $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/WnjAb on line 16 Fatal error: Uncaught Error: Call to a member function __invoke() on null in /in/WnjAb:16 Stack trace: #0 /in/WnjAb(20): ChuckNorrisException->__construct('Hello', Array) #1 {main} thrown in /in/WnjAb on line 16
Process exited with code 255.
Output for 7.0.18 - 7.0.33, 7.1.4 - 7.1.33, 7.2.0 - 7.2.33, 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/WnjAb on line 16 Fatal error: Uncaught Error: Call to a member function __invoke() on null in /in/WnjAb:16 Stack trace: #0 /in/WnjAb(21): ChuckNorrisException->__construct('Hello', Array) #1 {main} thrown in /in/WnjAb on line 16
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/WnjAb on line 16 Fatal error: Uncaught Error: Call to a member function __invoke() on null in /in/WnjAb:16 Stack trace: #0 /in/WnjAb(22): ChuckNorrisException->__construct('Hello', Array) #1 {main} thrown in /in/WnjAb on line 16
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
object(ChuckNorrisException)#1 (7) { ["message":protected]=> string(5) "Hello" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "Real Life" ["line":protected]=> int(20) ["trace":"Exception":private]=> array(1) { [0]=> array(4) { ["file"]=> string(19) "Chuck Norris, level" ["line"]=> int(99) ["class"]=> string(8) "own you " ["function"]=> string(14) "with uppercut!" } } ["previous":"Exception":private]=> NULL } Fatal error: Uncaught exception 'ChuckNorrisException' with message 'Hello' in Real Life:20 Stack trace: #0 Chuck Norris, level(99): own you with uppercut!() #1 {main} thrown in Real Life on line 20
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Fatal error: Call to undefined method Closure::bindTo() in /in/WnjAb on line 16
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/WnjAb on line 11
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/WnjAb on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/WnjAb on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/WnjAb on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/WnjAb on line 7
Process exited with code 255.

preferences:
298.93 ms | 401 KiB | 460 Q