summaryrefslogtreecommitdiff
path: root/ext/json/tests/003.phpt
blob: f10baa9d12ae41082d57cc0c69405d7258793611 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--TEST--
json_encode() & endless loop - 1
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php

$a = array();
$a[] = &$a;

var_dump($a);
var_dump(json_encode($a));

/* Break circular data structure to prevent memory leaks */
unset($a[0]);

echo "Done\n";
?>
--EXPECTF--	
array(1) {
  [0]=>
  &array(1) {
    [0]=>
    &array(1) {
      [0]=>
      *RECURSION*
    }
  }
}

Warning: json_encode(): recursion detected in %s on line %d
string(8) "[[null]]"
Done