3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = null; class A extends DateTime { public function __construct($d, $a) { global $a; $a = $this; parent::__construct($d, $a); throw new Exception("what?"); } public function __destruct() { echo "called\n"; } } try { $x = new A(10, 20); } catch(Exception $e) { } var_dump($a);
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught TypeError: DateTime::__construct() expects parameter 2 to be DateTimeZone, object given in /in/niSX6:8 Stack trace: #0 /in/niSX6(8): DateTime->__construct('10', Object(A)) #1 /in/niSX6(19): A->__construct(10, Object(A)) #2 {main} thrown in /in/niSX6 on line 8
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
object(A)#1 (3) { ["date"]=> string(26) "2012-09-15 07:06:28.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.2.1 - 5.6.28
object(A)#1 (0) { }
Output for 5.2.0
Warning: DateTime::__construct() expects parameter 2 to be DateTimeZone, object given in /in/niSX6 on line 8 object(A)#1 (0) { }
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/niSX6 on line 4
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/niSX6 on line 5
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/niSX6 on line 5
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/niSX6 on line 5
Process exited with code 255.