3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php var_dump(ini_get('zend.enable_gc')); class A { public static $B = array(); } class Controller { public function throwException() { throw new Exception("Test"); } } class ExceptionHandler { public function __construct() { set_exception_handler($this); } public function __invoke(Exception $e) { echo $exception->getMessage(); } } function error($no, $message) { throw new Exception($message); } set_error_handler('error'); A::$B['Handler'] = new ExceptionHandler; A::$B['Controller'] = new Controller; A::$B['Controller']->throwException();
Output for 7.0.0 - 7.1.0
string(1) "1" Fatal error: Uncaught Exception: Undefined variable: exception in /in/aRuC4:34 Stack trace: #0 /in/aRuC4(28): error(8, 'Undefined varia...', '/in/aRuC4', 28, Array) #1 [internal function]: ExceptionHandler->__invoke(Object(Exception)) #2 {main} thrown in /in/aRuC4 on line 34
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
bool(false) Fatal error: Uncaught exception 'Exception' with message 'Test' in /in/aRuC4:14 Stack trace: #0 /in/aRuC4(43): Controller->throwException() #1 {main} Exception handler threw an object exception: exception 'Exception' with message 'Undefined variable: exception' in /in/aRuC4:34 Stack trace: #0 /in/aRuC4(28): error() #1 (): ExceptionHandler->__invoke() #2 {main}
Process exited with code 255.
Output for 5.5.0 - 5.6.28
string(1) "1" Fatal error: Uncaught exception 'Exception' with message 'Undefined variable: exception' in /in/aRuC4:34 Stack trace: #0 /in/aRuC4(28): error(8, 'Undefined varia...', '/in/aRuC4', 28, Array) #1 [internal function]: ExceptionHandler->__invoke(Object(Exception)) #2 {main} thrown in /in/aRuC4 on line 34
Process exited with code 255.
Output for 5.3.18 - 5.3.29, 5.4.8 - 5.4.45
string(1) "1" Warning: Uncaught exception 'Exception' with message 'Undefined variable: exception' in /in/aRuC4:34 Stack trace: #0 /in/aRuC4(28): error(8, 'Undefined varia...', '/in/aRuC4', 28, Array) #1 [internal function]: ExceptionHandler->__invoke(Object(Exception)) #2 {main} thrown in /in/aRuC4 on line 34 Fatal error: Call to a member function getMessage() on a non-object in /in/aRuC4 on line 28
Process exited with code 255.
Output for 5.3.3 - 5.3.17, 5.4.0 - 5.4.7
string(1) "1" Fatal error: Call to a member function getMessage() on a non-object in /in/aRuC4 on line 28
Process exited with code 255.
Output for 5.3.0 - 5.3.2
string(1) "1" Fatal error: Call to a member function getMessage() on a non-object in /in/aRuC4 on line 0
Process exited with code 255.
Output for 5.2.0 - 5.2.17
string(0) "" Fatal error: Uncaught exception 'Exception' with message 'Object of class ExceptionHandler could not be converted to string' in /in/aRuC4:34 Stack trace: #0 [internal function]: error(4096, 'Object of class...', '/in/aRuC4', 23, Array) #1 /in/aRuC4(23): set_exception_handler(Object(ExceptionHandler)) #2 /in/aRuC4(40): ExceptionHandler->__construct() #3 {main} thrown in /in/aRuC4 on line 34
Process exited with code 255.
Output for 5.0.5 - 5.1.6
string(0) "" Fatal error: Uncaught exception 'Exception' with message 'set_exception_handler() expects the argument (Object id #1) to be a valid callback' in /in/aRuC4:34 Stack trace: #0 [internal function]: error(2, 'set_exception_h...', '/in/aRuC4', 23, Array) #1 /in/aRuC4(23): set_exception_handler(Object(ExceptionHandler)) #2 /in/aRuC4(40): ExceptionHandler->__construct() #3 {main} thrown in /in/aRuC4 on line 34
Process exited with code 255.
Output for 5.0.3 - 5.0.4
string(0) "" Fatal error: Uncaught exception 'Exception' with message 'set_exception_handler() expects the argument (Object id #1) to be a valid callback' in /in/aRuC4:34 Stack trace: #0 /in/aRuC4(34): error() #1 /in/aRuC4(23): error(2, 'set_exception_h...', '/in/aRuC4', 23, Array) #2 /in/aRuC4(23): set_exception_handler(Object(ExceptionHandler)) #3 /in/aRuC4(40): ExceptionHandler->__construct() #4 {main} thrown in /in/aRuC4 on line 34
Process exited with code 255.
Output for 5.0.0 - 5.0.2
string(0) "" Fatal error: Uncaught exception 'Exception' with message 'set_exception_handler() expects the argument (Object id #1) to be a valid callback' in /in/aRuC4:34 Stack trace: #0 /in/aRuC4(23): error(2, 'set_exception_h...', '/in/aRuC4', 23, Array) #1 /in/aRuC4(23): set_exception_handler(Object(ExceptionHandler)) #2 /in/aRuC4(40): ExceptionHandler->__construct() #3 {main} thrown in /in/aRuC4 on line 34
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/aRuC4 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/aRuC4 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/aRuC4 on line 7
Process exited with code 255.