xref: /PHP-7.4/ext/json/tests/bug54484.phpt (revision e5abc537)
1--TEST--
2Bug #54484 (Empty string in json_decode doesn't reset json_last_error)
3--SKIPIF--
4<?php if (!extension_loaded("json")) print "skip"; ?>
5--FILE--
6<?php
7json_decode('{"test":"test"}');
8var_dump(json_last_error());
9
10json_decode("");
11var_dump(json_last_error());
12
13json_decode("invalid json");
14var_dump(json_last_error());
15
16json_decode("\"\001 invalid json\"");
17var_dump(json_last_error());
18
19json_decode("");
20var_dump(json_last_error());
21?>
22--EXPECT--
23int(0)
24int(4)
25int(4)
26int(3)
27int(4)
28