3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class B implements JsonSerializable { public function jsonSerialize() { return array( 'Recursion' => array( 'across' => array( 'multiple' => array('levels' => $this) ) ) ); } } var_dump(json_encode(new B(), JSON_PARTIAL_OUTPUT_ON_ERROR));
based on VcIGl
Output for 5.5.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
string(102) "{"Recursion":{"across":{"multiple":{"levels":{"Recursion":{"across":{"multiple":{"levels":null}}}}}}}}"
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/Ldd3X on line 16 Warning: json_encode() expects parameter 2 to be long, string given in /in/Ldd3X on line 16 NULL
Output for 5.0.5 - 5.3.29
Fatal error: Interface 'JsonSerializable' not found in /in/Ldd3X on line 2
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Fatal error: Class 'JsonSerializable' not found in /in/Ldd3X on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/Ldd3X on line 2
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/Ldd3X on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/Ldd3X on line 2
Process exited with code 255.