php json中 数据有"双引号怎么办?
1个回答
展开全部
可以使用PHP addslashes() 函数转义一下
addslashes() 函数在指定的预定义字符前添加反斜杠。
这些预定义字符是:
单引号 (')
双引号 (")
反斜杠 (\)
NULL
例如:
<?php
$str = "Who's John Adams?";
echo $str . " This is not safe in a database query.<br />";
echo addslashes($str) . " This is safe in a database query.";
?>
输出:
Who's John Adams? This is not safe in a database query.
Who\'s John Adams? This is safe in a database query.
addslashes() 函数在指定的预定义字符前添加反斜杠。
这些预定义字符是:
单引号 (')
双引号 (")
反斜杠 (\)
NULL
例如:
<?php
$str = "Who's John Adams?";
echo $str . " This is not safe in a database query.<br />";
echo addslashes($str) . " This is safe in a database query.";
?>
输出:
Who's John Adams? This is not safe in a database query.
Who\'s John Adams? This is safe in a database query.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询