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