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, 5); var_dump($result);
based on eTZ6T
Output for 5.5.0 - 7.2.0
string(50) "[{},{"a":1,"b":{"a":1},"c":{"z":{"a":1}}},{"a":1}]"
Output for 5.3.0 - 5.4.45
NULL
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA on line 9 NULL
Output for 4.3.2 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA 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/NOLQA on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NOLQA on line 9