我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在PHP中为JSON输出删除引号

I have a string in PHP that contains both single and double quotes.

I am trying to use this string in some JSON output. To do this I need to escape double quotes, slashes, newlines etc.

I thought that addslashes() would do the job but it also escapes single quotes which causes the JSON to fail.

How can I escape all relevant special characters except for single quotes?

json_encode() will handle all that for you.

近期文章

  • 使用PHP嵌入图像
  • MySQL中的负索引长度
  • html get方法 - 两个单词的值问题
  • 奇怪的JavaScript,PHP和Google Maps行为
  • 如何解析xml以将其插入到mysql数据库中?
  • 如何将可变数量的参数传递给PHP中的函数
  • 简单正则表达式,用于检测以z开头但不是zz的字符串
  • 数组声明
  • springboot mybatis atomikos 事务超时未提交 求解
  • tensorflow中张量名字引号后面的数字是什么?
  • 求大神 pringboot mybatis atomikos 事务超时未提交 要怎么解决呀!!!
  • 谁帮我看看这是个什么原因。。
  • 简单的Python句式问题
  • Appserv mcrypt与Windows 7
  • PHP的公式解释
  • 在文本框中显示两个值
  • select * from table不起作用
  • PHP对象参数行为
  • php打印10个数组的结果
  • 我的SQL查询出了什么问题?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华