Why are escape characters being added to the value of the hidden input
html, json, php
Solution
Check whether your PHP configuration has `magic_quotes_gpc` activated, in such case the PHP server automatically adds slashes to GET/POST/cookie values...
Problem
``` <body> <div> <?= $_POST['msg'] ?> </div> <form id="frm" method="post"> <input type="hidden" name='msg' value='{"field0": "Im a string", "field1": 84, "field3": "so am I"}' /> <input type="submit" value="test" /> </form> </body> ``` When the form is posted, the following string is displayed between the div tags. {\"field0\": \"Im a string\", \"field1\": 84, \"field3\": \"so am I\"} Why are the escape characters being added? Are they being added by the PHP server or the web client? Can I do anything to prevent this? Someone already mentioned the PHP function stripslashes. I'm using it for now but I want to get rid of the slashes all together.