php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66027 json_encode returns 'null' string instead of false on error
Submitted: 2013-11-03 16:31 UTC Modified: 2013-11-03 17:19 UTC
From: vseticka dot martin at gmail dot com Assigned: nikic (profile)
Status: Closed Package: JSON related
PHP Version: 5.4.21 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vseticka dot martin at gmail dot com
New email:
PHP Version: OS:

 

 [2013-11-03 16:31 UTC] vseticka dot martin at gmail dot com
Description:
------------
The script shows that json_encode function does not return FALSE on JSON_ERROR_UTF8 error as stated in manual page http://php.net/manual/en/function.json-encode.php but it returns "null" string.

Test script:
---------------
$result = json_encode(iconv('UTF-8', 'UCS-2', "Příliš žluťoučký kůň úpěl ďábelské ódy."));
var_dump(json_last_error());
var_dump($result);

Expected result:
----------------
int(5)
bool(false)


Actual result:
--------------
int(5)
string(4) "null"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-03 17:19 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2013-11-03 17:19 UTC] nikic@php.net
Has already been fixed in 5.5
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Apr 16 15:01:24 2021 UTC