[PHP] json_decode error by wrong json string with quotes

PHP json_decode fails when the JSON string from $_POST has added backslashes. The root cause is the magic_quotes setting in php.ini — disable it to fix the issue.

Normal json string:

1
{"Hey":"There"}

Error json string got from $_POST variable:

1
{\"Hey\":\"There\"}

This may causes by magic_quotes in php.ini
Magic is never good in development.

comments powered by Disqus
Powered by Hugo. Theme Stack. All Rights Reserved.