ITADN

`json_encode()` errors don't clear the error position

#22420OpenTimWolla 创建于 2026-06-24
BugExtension: jsonStatus: Verified
T
TimWollacommented
### Description The following code: ```php <?php var_dump(json_decode('{132')); var_dump(json_last_error_msg()); var_dump(json_encode("\xFE\xD0")); var_dump(json_last_error_msg()); ``` Resulted in this output: ``` NULL string(30) "Syntax error near location 1:2" bool(false) string(74) "Malformed UTF-8 characters, possibly incorrectly encoded near location 1:2" ``` But I expected this output instead: ``` NULL string(30) "Syntax error near location 1:2" bool(false) string(56) "Malformed UTF-8 characters, possibly incorrectly encoded" ``` ### PHP Version ```plain PHP 8.6.0-dev (cli) (built: Jun 24 2026 10:30:47) (NTS DEBUG) Copyright © The PHP Group and Contributors Zend Engine v4.6.0-dev, Copyright © Zend by Perforce with Zend OPcache v8.6.0-dev, Copyright ©, by Zend by Perforce ``` ### Operating System _No response_
0 条评论