Bug #72417 [Opn->Nab]: Empty string causes a syntax error

From: Date: Wed, 15 Jun 2016 16:59:37 +0000
Subject: Bug #72417 [Opn->Nab]: Empty string causes a syntax error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201662@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72417&edit=1 ID: 72417 Updated by: nikic@php.net Reported by: jonathan at spoonity dot com Summary: Empty string causes a syntax error -Status: Open +Status: Not a bug Type: Bug Package: JSON related Operating System: CentOS Linux release 7.2.1511 PHP Version: 7.0.7 Block user comment: N Private report: N New Comment: This is an intentional change. An empty string is not valid JSON. Previous Comments: ------------------------------------------------------------------------ [2016-06-15 15:55:11] 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) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72417&edit=1

« previous php.bugs (#201662) next »