3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('America/New_York'); $date = new DateTime(); echo json_encode($date,JSON_FORCE_OBJECT); var_dump(json_last_error(), json_last_error_msg()); function isSerializable( $var ) { try { serialize( $var ); return TRUE; } catch( Exception $e ) { return FALSE; } } var_dump( isSerializable( array() ) ); // bool(true) var_dump( isSerializable( function() {} ) ); // bool(false) var_dump( isSerializable( array( function() {} ) ) );
Output for 7.1.0
{"date":"2014-06-19 23:13:57.004064","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" bool(true) bool(false) bool(false)
Output for 5.5.14 - 7.0.14
{"date":"2014-06-19 23:13:57.000000","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" bool(true) bool(false) bool(false)
Output for 5.5.0 - 5.5.13
{"date":"2014-06-19 23:13:57","timezone_type":3,"timezone":"America\/New_York"}int(0) string(8) "No error" bool(true) bool(false) bool(false)
Output for 5.4.30 - 5.4.45
{"date":"2014-06-19 23:13:57.000000","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/5FEbj on line 8
Process exited with code 255.
Output for 5.3.0 - 5.4.29
{"date":"2014-06-19 23:13:57","timezone_type":3,"timezone":"America\/New_York"} Fatal error: Call to undefined function json_last_error_msg() in /in/5FEbj on line 8
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/5FEbj on line 21
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/5FEbj on line 21
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/5FEbj on line 12
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/5FEbj on line 12
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/5FEbj on line 12
Process exited with code 255.