php 自动为引号添加斜杠 [英] php automatically adds slashes to quotes

查看:25
本文介绍了php 自动为引号添加斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做的就是获取 xml 文件内容,显示在 textarea 中并在提交 for 时更新文件内容.我使用此代码:

All I'm trying to do is to get xml file content, show is in the textarea and update the file content if the for is submited. I use this code:

$fname = "../data.xml";

if (isset($_POST["update"])) {
 $content = $_POST["update"];
 $fhandle = fopen($fname,"w");
 fwrite($fhandle,$content);
}

$fhandle = fopen($fname,"r");
$content = fread($fhandle,filesize($fname));

fclose($fhandle);

当我按下提交时内容会更新,但它会在引号中添加斜杠.例如这段代码:

The content is updated when I press submit but it adds slashes to quotes. For example this code:

<?xml version="1.0" encoding="utf-8"?>

变成:

<?xml version=\"1.0\" encoding=\"utf-8\"?>

如果我重新提交:

<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>

谁能告诉我我做错了什么?

Can anyone please tell what am I doing wrong?

提前致谢

推荐答案

这是 Magic Quotes 的问题,我们也遇到了.对 POST 输入使用 stripslashes(),然后再对其进行任何操作.

This is an issue with Magic Quotes, we ran into it as well. Use stripslashes() on the POST input before doing anything with it.

这篇关于php 自动为引号添加斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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