Is there a PHP function that only adds slashes to double quotes NOT single quotes

后端 未结 4 1193
Happy的楠姐
Happy的楠姐 2020-12-09 08:06

I am generating JSON with PHP.

I have been using

$string = \'This string has \"double quotes\"\';

echo addslashes($string);

output

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 08:50

    If you are generating JSON, why not just use the json_encode() function ?

提交回复
热议问题