xref: /PHP-7.1/ext/json/tests/002.phpt (revision 7af945e2)
1--TEST--
2json_encode() tests
3--SKIPIF--
4<?php if (!extension_loaded("json")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(json_encode(""));
9var_dump(json_encode(NULL));
10var_dump(json_encode(TRUE));
11
12var_dump(json_encode(array(""=>"")));
13var_dump(json_encode(array(array(1))));
14var_dump(json_encode(array()));
15
16var_dump(json_encode(array(""=>""), JSON_FORCE_OBJECT));
17var_dump(json_encode(array(array(1)), JSON_FORCE_OBJECT));
18var_dump(json_encode(array(), JSON_FORCE_OBJECT));
19
20var_dump(json_encode(1));
21var_dump(json_encode("руссиш"));
22
23echo "Done\n";
24?>
25--EXPECTF--
26string(2) """"
27string(4) "null"
28string(4) "true"
29string(7) "{"":""}"
30string(5) "[[1]]"
31string(2) "[]"
32string(7) "{"":""}"
33string(13) "{"0":{"0":1}}"
34string(2) "{}"
35string(1) "1"
36string(38) ""\u0440\u0443\u0441\u0441\u0438\u0448""
37Done
38