3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $so = new \stdClass; $so->a = 1; $obj = new \stdClass(); $obj->z = $so; $arr = array(new \stdClass(), array('a' => 1, 'b' => $so, 'c' => $obj), $so); $result = @json_encode($arr, 0, 6); var_dump($result, json_last_error(), json_last_error_msg());
based on e8ufc
Output for 5.5.0 - 7.2.0
string(50) "[{},{"a":1,"b":{"a":1},"c":{"z":{"a":1}}},{"a":1}]" int(0) string(8) "No error"
Output for 5.3.0 - 5.4.45
Fatal error: Call to undefined function json_last_error_msg() in /in/cBYTI on line 13
Process exited with code 255.
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 9 Fatal error: Call to undefined function json_last_error() in /in/cBYTI on line 13
Process exited with code 255.
Output for 4.3.2 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/cBYTI on line 9