|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-23 00:45 UTC] felipe@php.net
[2008-07-22 17:33 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
Description: ------------ When a single quote is being escaped, the json_decode() gives some unexpected results. 1. According to the JSON specs, the single quote is not in the list of characters that can follow the escape character (such as n, t, b, r, etc.); however, JavaScript does recognize the single quote so it would be very nice to have as a feature. 2. When wrapping a string with an escaped single quote inside an array context, the json_decode() gives up and returns NULL. Reproduce code: --------------- <?php $s = '"Sir, you\\\'re an idiot!"'; var_dump(json_decode($s)); var_dump(json_decode("[$s]")); ?> Expected result: ---------------- string(21) "Sir, you're an idiot!" array(1) { [0]=> string(21) "Sir, you're an idiot!" } Actual result: -------------- string(22) "Sir, you\'re an idiot!" NULL