PHP,为什么您不引用我的引号? [英] PHP, why do you escape my quotes?

查看:79
本文介绍了PHP,为什么您不引用我的引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
为什么要添加转义字符到隐藏输入的值

Possible Duplicate:
Why are escape characters being added to the value of the hidden input

所以,我有一个名为Save.php的文件.

So, I have a file called Save.php.

这需要两件事:一个文件和新内容.

It takes two things: a file, and the new contents.

您通过发送类似'/Resources/Save.php?file=/Resources/Data.json&contents={"Hey":"There"}'的请求来使用它.

You use it by sending a request like '/Resources/Save.php?file=/Resources/Data.json&contents={"Hey":"There"}'.

..但是当然要对网址进行编码. :)为了简化和可读性,我不做任何编码.

..but of course, encoding the url. :) I left it all unencoded for simplicity and readability.

该文件可以工作,但不能代替内容.

The file works, but instead of the contents being..

{"Hey":"There"}

..我找到了.

{\"Hey\":\"There\"}

..当稍后通过XHR获取JSON文件时尝试使用JSON.parse时,当然会抛出错误.

..which of course throws an error when trying to use JSON.parse when getting the JSON file later through XHR.

要保存内容,我只用..

To save the contents, I just use..

file_put_contents($url, $contents);

我该怎么做才能消除反斜杠?

What can I do to get rid of the backslashes?

推荐答案

打开 magic_quotes 在PHP.ini中关闭.

Turn magic_quotes off in PHP.ini.

这篇关于PHP,为什么您不引用我的引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆