Skip to content

Unterminated JSON strings are misleadingly reported as “Control character error” #22527

Description

@TimWolla

Description

The following code:

<?php

var_dump(json_decode('"'), json_last_error_msg());

Resulted in this output:

NULL
string(53) "Control character error, possibly incorrectly encoded"

But I expected this output instead: Something about EOF being reached.

PHP Version

PHP 8.5.7 (cli) (built: Jun  6 2026 05:36:56) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.7, Copyright (c), by Zend Technologies

Operating System

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions