php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72417 Empty string causes a syntax error
Submitted: 2016-06-15 15:55 UTC Modified: 2016-06-15 16:59 UTC
From: jonathan at spoonity dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 7.0.7 OS: CentOS Linux release 7.2.1511
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jonathan at spoonity dot com
New email:
PHP Version: OS:

 

 [2016-06-15 15:55 UTC] jonathan at spoonity dot com
Description:
------------
Prior to PHP 7, the behaviour of an empty string when doing a json_decode() would not cause any error to occur, now with PHP 7 it causes a syntax error to occur.

Test script:
---------------
json_decode("");

if (json_last_error() > 0) {
    echo sprintf("%s (%d)\n", json_last_error_msg(), json_last_error());
}

Expected result:
----------------
No error returned

Actual result:
--------------
Error returned; Syntax error (4)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-15 16:59 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2016-06-15 16:59 UTC] nikic@php.net
This is an intentional change. An empty string is not valid JSON.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC