note 82384 added to function.json-decode

From: Date: Tue, 08 Apr 2008 21:40:37 +0000
Subject: note 82384 added to function.json-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-138038@lists.php.net to get a copy of this message
@AMA3: "It's strange that forward-slash is permitted to be escaped but not required to be, and that it has the same meaning either way, but that's how it's written, and so shall it be." JavaScript ignores '\' characters that don't start any sort of escape sequence, so as far as it is concerned, "\/" is equivalent to "/" (ECMA-262, §7.8.4). So in that sense it's permitted but not required to be: so why do it? json_encode("</script>") will produce "<\/script>" so that HTML parsers don't see a </script> end tag and choke on it (to play it safe and simplify the implementation, it escapes all '/'s); json_decode() therefore has to cope with that. As for it being necessary, I agree: it isn't on MY machine :) json_decode('{"a":"<p>test<\/p>"}'); ==> (object)array('a' => '<p>test</p>'); json_decode('{"a":"<p>test</p>"}'); ==> (object)array('a' => '<p>test</p>'); ---- Server IP: 202.89.58.1 Probable Submitter: 60.234.168.92 ---- Manual Page -- http://www.php.net/manual/en/function.json-decode.php Edit -- https://master.php.net/note/edit/82384 Del: integrated -- https://master.php.net/note/delete/82384/integrated Del: useless -- https://master.php.net/note/delete/82384/useless Del: bad code -- https://master.php.net/note/delete/82384/bad+code Del: spam -- https://master.php.net/note/delete/82384/spam Del: non-english -- https://master.php.net/note/delete/82384/non-english Del: in docs -- https://master.php.net/note/delete/82384/in+docs Del: other reasons-- https://master.php.net/note/delete/82384 Reject -- https://master.php.net/note/reject/82384 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#138038) next »