$a = '{ "tag": "<b></b>" }';
echo json_encode( json_decode($a) );
This outputs:
{"tag":"<b><\/b>"}
when you would think it would output exactly the input. For some reason json_encode adds an extra slash.
Because it's part of the JSON standard
http://json.org/
char
any-Unicode-character- except-"-or-\-or- control-character \" \\ \/ <---- see here? \b \f \n \r \t \u four-hex-digits
use this:
echo json_encode($a,JSON_HEX_TAG)
Result will be:
["\u003C\u003E"]
You can read this article to improve your knowledge about JSON_ENCODE http://php.net/manual/en/function.json-encode.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With