xref: /PHP-7.1/ext/json/tests/003.phpt (revision 7af945e2)
1--TEST--
2json_encode() & endless loop - 1
3--SKIPIF--
4<?php if (!extension_loaded("json")) print "skip"; ?>
5--FILE--
6<?php
7
8$a = array();
9$a[] = &$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--
26array(1) {
27  [0]=>
28  &array(1) {
29    [0]=>
30    *RECURSION*
31  }
32}
33
34bool(false)
35int(6)
36string(%d) "Recursion detected"
37
38string(8) "[[null]]"
39int(6)
40string(%d) "Recursion detected"
41Done
42