3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 7.0.0 - 7.1.0
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 hhvm-3.10.0 - 3.12.0
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(22) ["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 } Notice: Undefined index: type Notice: Undefined index: type Fatal error: Uncaught exception 'ChuckNorrisException' with message 'Hello' in Real Life:22 Stack trace: #0 Chuck Norris, level(99): own you with uppercut!() #1 {main}
Process exited with code 255.
Output for 5.4.0 - 5.6.28
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.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.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.