|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52161 json_encode encoding HTML tags within strings incorrectly
Submitted: 2010-06-23 18:22 UTC Modified: 2010-08-09 03:21 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: niazuddin dot ahmed at gmail dot com Assigned: felipe (profile)
Status: Closed Package: JSON related
PHP Version: 5.3.2 OS: RedHat
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.
Bug Type:
From: niazuddin dot ahmed at gmail dot com
New email:
PHP Version: OS:


 [2010-06-23 18:22 UTC] niazuddin dot ahmed at gmail dot com
When using json_encode for strings with HTML tag, end tag gets HTML encoded but the start tag is left alone 

Test script:
echo json_encode(array('test' => '<b>Bold</b>'));

Expected result:

This is valid JSON as per

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-23 22:54 UTC]
-Status: Open +Status: Feedback
 [2010-06-23 22:54 UTC]
Please try using this snapshot:
For Windows:

can't reproduce
 [2010-08-09 03:21 UTC]
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-08-09 03:21 UTC]
I got the expected result. Closed.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 07:01:30 2024 UTC