xref: /PHP-8.3/ext/json/tests/bug64874_part2.phpt (revision 7aacc705)
1--TEST--
2Case-sensitivity part of bug #64874 ("json_decode handles whitespace and case-sensitivity incorrectly")
3--FILE--
4<?php
5function decode($json) {
6    var_dump(json_decode($json));
7    echo ((json_last_error() !== 0) ? 'ERROR' : 'SUCCESS') . PHP_EOL;
8}
9
10// Only lowercase should work
11decode('true');
12decode('True');
13decode('[true]');
14decode('[True]');
15echo PHP_EOL;
16
17decode('false');
18decode('False');
19decode('[false]');
20decode('[False]');
21echo PHP_EOL;
22
23decode('null');
24decode('Null');
25decode('[null]');
26decode('[Null]');
27echo PHP_EOL;
28
29echo "Done\n";
30?>
31--EXPECT--
32bool(true)
33SUCCESS
34NULL
35ERROR
36array(1) {
37  [0]=>
38  bool(true)
39}
40SUCCESS
41NULL
42ERROR
43
44bool(false)
45SUCCESS
46NULL
47ERROR
48array(1) {
49  [0]=>
50  bool(false)
51}
52SUCCESS
53NULL
54ERROR
55
56NULL
57SUCCESS
58NULL
59ERROR
60array(1) {
61  [0]=>
62  NULL
63}
64SUCCESS
65NULL
66ERROR
67
68Done
69