<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.
Check whether your PHP configuration has magic_quotes_gpc
activated, in such case the PHP server automatically adds slashes to GET/POST/cookie values...
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