Why does JSON encoder adds escaping character when encoding URLs?

后端 未结 5 2057
太阳男子
太阳男子 2020-12-17 17:15

I am using json_encode in PHP to encode an URL

$json_string = array (\'myUrl\'=> \'http://example.com\');
echo json_encode ($json_string);
         


        
5条回答
  •  感动是毒
    2020-12-17 17:31

    I think this solves your problem

    json_encode ($json_string, JSON_UNESCAPED_SLASHES );
    

    You can see the documentation:

    https://www.php.net/manual/en/function.json-encode.php

    https://www.php.net/manual/en/json.constants.php

提交回复
热议问题