|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-02-15 10:07 UTC] marco dot biondi at docomodigital dot com
Description: ------------ --- From manual page: https://php.net/function.json-encode --- Just look at the sample code Test script: --------------- <?php $a = "Srting with a slash: \ Just a slash is that I want!"; $b = "Srting with a slash: \\ Just a slash is that I want!"; var_dump($a); var_dump(json_encode($a)); var_dump($b); var_dump(json_encode($b)); Expected result: ---------------- string(51) "Srting with a slash: \ Just a slash is that I want!" string(53) ""Srting with a slash: \ Just a slash is that I want!"" string(51) "Srting with a slash: \ Just a slash is that I want!" string(53) ""Srting with a slash: \ Just a slash is that I want!"" Actual result: -------------- string(51) "Srting with a slash: \ Just a slash is that I want!" string(54) ""Srting with a slash: \\ Just a slash is that I want!"" string(51) "Srting with a slash: \ Just a slash is that I want!" string(54) ""Srting with a slash: \\ Just a slash is that I want!"" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 09:00:01 2025 UTC |
A proper Unicode escape in PHP would be \u{00BF}, and this works as expected: <https://3v4l.org/OCqmT>.