JSON转义URL斜杠处理

给转json的地方加JSON_UNESCAPED_SLASHES即可

下面是未加的

$json = json_encode(array(
    'code' => 200,
    'data' => $dst,
    'error' => ''
));

返回前端是:

{"code":200,"data":"https:\/\/xxxx.com\/files\/b73bf4615176deea40dda5aad9c38438.png","error":""}

下面是加的:

$json = json_encode(array(
    'code' => 200,
    'data' => $dst,
    'error' => ''
),JSON_UNESCAPED_SLASHES);

返回前端是:
{“code”:200,“data”:“https://xxxx.com/files/b73bf4615176deea40dda5aad9c38438.png”,“error”:""}

©️2020 CSDN 皮肤主题: 1024 设计师:上身试试 返回首页