3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dt = new DateTime( null ); $serial = serialize( $dt ); var_dump( '1', unserialize( $serial ) ); $test = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-03-31 14:55:58";s:13:"timezone_type";i:3;s:8:"timezone";s:12:"Europe/Paris";}'; var_dump( '2', unserialize( $test ) ); try { $test = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-03-31 14:55:58";s:13:"timezone_type";i:3;s:8:"timezone";s:0:"";}'; var_dump( '3', unserialize( $test ) ); } catch ( \Exception $e ) { var_dump( '3', 'err' ); }
Output for 7.1.0
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-25 19:54:29.006340" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 14:55:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } Fatal error: Uncaught Error: Invalid serialization data for DateTime object in /in/CH9Bs:13 Stack trace: #0 [internal function]: DateTime->__wakeup() #1 /in/CH9Bs(13): unserialize('O:8:"DateTime":...') #2 {main} thrown in /in/CH9Bs on line 13
Process exited with code 255.
Output for 5.4.30 - 5.4.45, 5.5.14 - 5.6.28, 7.0.0 - 7.0.14
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-25 19:54:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 14:55:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } Fatal error: Invalid serialization data for DateTime object in /in/CH9Bs on line 13
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught exception 'Exception' with message '__construct() expects parameter 1 to be string, null given' in /in/CH9Bs:3 Stack trace: #0 /in/CH9Bs(3): DateTime->__construct() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(26) "2015-11-25 19:54:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-31 14:55:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } string(1) "3" string(3) "err"
Output for 5.4.28 - 5.4.29, 5.5.12 - 5.5.13
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-25 19:54:29" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } Fatal error: Invalid serialization data for DateTime object in /in/CH9Bs on line 13
Process exited with code 255.
Output for 5.3.0 - 5.4.27, 5.5.0 - 5.5.11
string(1) "1" object(DateTime)#2 (3) { ["date"]=> string(19) "2015-11-25 19:54:29" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" }
Process exited with code 139.
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/CH9Bs on line 15 string(1) "1" object(DateTime)#2 (0) { } string(1) "2" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(12) "Europe/Paris" } string(1) "3" object(DateTime)#2 (3) { ["date"]=> string(19) "2014-03-31 14:55:58" ["timezone_type"]=> int(3) ["timezone"]=> string(0) "" }
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/CH9Bs on line 15 Fatal error: Class 'DateTime' not found in /in/CH9Bs on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/CH9Bs on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '{' in /in/CH9Bs on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/CH9Bs on line 11
Process exited with code 255.