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