3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class test implements JsonSerializable { public $a = 2; public function JsonSerialize() { return $this; } } var_dump(json_encode(new test(), JSON_PARTIAL_OUTPUT_ON_ERROR)); var_dump(json_last_error_msg());
based on VcIGl
Output for 5.5.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(7) "{"a":2}" string(8) "No error"
Output for 5.4.0 - 5.4.45
Notice: Use of undefined constant JSON_PARTIAL_OUTPUT_ON_ERROR - assumed 'JSON_PARTIAL_OUTPUT_ON_ERROR' in /in/9nYRL on line 10 Warning: json_encode() expects parameter 2 to be long, string given in /in/9nYRL on line 10 NULL Fatal error: Call to undefined function json_last_error_msg() in /in/9nYRL on line 11
Process exited with code 255.
Output for 5.0.5 - 5.3.29
Fatal error: Interface 'JsonSerializable' not found in /in/9nYRL on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Fatal error: Class 'JsonSerializable' not found in /in/9nYRL on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/9nYRL on line 3
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 '{' in /in/9nYRL on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/9nYRL on line 3
Process exited with code 255.