|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #67469 json_encode changed behaviour in 5.5
Submitted: 2014-06-18 20:06 UTC Modified: 2017-04-28 19:33 UTC
Avg. Score:4.5 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: martin at ringehahn dot de Assigned: bukka (profile)
Status: Closed Package: JSON related
PHP Version: 5.5.13 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: martin at ringehahn dot de
New email:
PHP Version: OS:


 [2014-06-18 20:06 UTC] martin at ringehahn dot de
It appears that in 5.5, "#61537 json_encode() incorrectly truncates/discards information" has been addressed. php 5.4 and 5.3 also had this patch at some point but it was reverted later. I assume this was done for not breaking backcompat in point releases.

However, the php 5.5 Changelog fails to mentioned that json_encode changed behaviour and now behaves as documented. specifically: "Returns a JSON encoded string on success or FALSE on failure."

the documentation also fails to mention the new constant `JSON_PARTIAL_OUTPUT_ON_ERROR`. well, it actually mentions it by referencing to it but it is not listed as a proper item.

Test script:
echo json_encode(["foo" => chr(132), "bar" => "bar"]);
// nothing, false
// this used to return "Expected result"

Expected result:
since the Changelog does not mention anything json-related, I'd expect the same behaviour as in previous versions:

echo json_encode(["foo" => chr(132), "bar" => "bar"]);
PHP Warning:  json_encode(): Invalid UTF-8 sequence in argument in php shell code on line 1

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-20 08:13 UTC] arjen at react dot com
Your expected result was only the case for PHP 5.3.14, which was the result of not reverting a fix on time (see

Documentation could be updated, but the current behaviour seems fine to me.
 [2014-06-20 12:55 UTC] martin at ringehahn dot de

This is filed as a "Doc Bug" for a reason. Your link shows that between 5.4.29 (most recent 5.4) and 5.5.0 function has changed its behaviour. This has not been documented anywhere. Specifically: or do not mention this change of behaviour.
 [2017-03-31 17:35 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bukka
 [2017-03-31 17:45 UTC]
Fix committed to docs:

Log: Fix doc bug #67496 (json_encode changed behaviour in 5.5)

P.S. Sorry for the wrong bug number in comment above (not 67496 but 67469...)
 [2017-04-28 19:33 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 00:01:28 2024 UTC