|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52172 Impossible to escape escape character
Submitted: 2010-06-24 16:35 UTC Modified: 2010-06-24 17:00 UTC
From: harald dot lapp at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.3.2 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: harald dot lapp at gmail dot com
New email:
PHP Version: OS:


 [2010-06-24 16:35 UTC] harald dot lapp at gmail dot com
Apparently it's impossible to decode strings with escaped "escape" character: 


this should work however, as it's written in the json specs on

Test script:

var_dump(json_decode('["\\"]', true));


Expected result:
array(1) {
  string(1) "\"

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-24 16:51 UTC]
-Status: Open +Status: Bogus
 [2010-06-24 16:51 UTC]
You are confusing PHP escapes and json escapes.


php > $str = '["\\"]';
php > echo $str;

That's obviously not valid json.  What you actually want:

php > $str = '["\\\\"]';
php > echo $str;
php > var_dump(json_decode($str));
array(1) {
  string(1) "\"

Works fine.  No bug here.
 [2010-06-24 17:00 UTC] harald dot lapp at gmail dot com
you are right, of course -- i got confused. sorry for reporting and thanks for fast reply!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 06:01:31 2024 UTC