xref: /php-src/ext/json/tests/004.phpt (revision 32a1ebbd)
1--TEST--
2json_encode() & endless loop - 2
3--FILE--
4<?php
5
6$a = new stdclass;
7$a->prop = $a;
8
9var_dump($a);
10
11echo "\n";
12
13var_dump(json_encode($a));
14var_dump(json_last_error(), json_last_error_msg());
15
16echo "\n";
17
18var_dump(json_encode($a, JSON_PARTIAL_OUTPUT_ON_ERROR));
19var_dump(json_last_error(), json_last_error_msg());
20
21echo "Done\n";
22?>
23--EXPECTF--
24object(stdClass)#%d (1) {
25  ["prop"]=>
26  *RECURSION*
27}
28
29bool(false)
30int(6)
31string(%d) "Recursion detected"
32
33string(13) "{"prop":null}"
34int(6)
35string(%d) "Recursion detected"
36Done
37