“每个引号前的斜线"问题 [英] "slash before every quote" problem

查看:20
本文介绍了“每个引号前的斜线"问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含表单的 php 页面.

I have a php page which contains a form.

有时这个页面会被提交给它自己(比如上传图片时).

Sometimes this page is submitted to itself (like when pics are uploaded).

我不希望用户必须一次又一次地填写每个字段,因此我将其用作表单内文本输入的值:

I wouldn't want users to have to fill in every field again and again, so I use this as a value of a text-input inside the form:

value="<?php echo htmlentities(@$_POST['annonsera_headline'],ENT_COMPAT,'UTF-8');?>">

这是有效的,只是它在每个双引号前添加了一个\"符号...

This works, except it adds a "\" sign before every double-quote...

例如在页面提交给自身后写入 19" 轮子:

For instance writing 19" wheels gives after page is submitted to itself:

  19\" wheels

如果我什至不使用 htmlentities,那么引号后的所有内容都会消失.

And if I don't even use htmlentities then everything after the quotes dissappears.

这里有什么问题?

更新:

好的,所以问题是magic_quotes...这在我的服务器上启用...

Okay, so the prob is magic_quotes... This is enabled on my server...

我应该禁用它吗?我有 root 访问权限,它是我的服务器 :)

Should I disable it? I have root access and it is my server :)

禁用它有什么危害?

推荐答案

看起来你有 魔法语录 已打开.使用以下条件使用 stripslashes 使用您要处理的任何文本:

Looks like you have magic quotes turned on. Use below condition using stripslashes with whatever text you want to process:

if(get_magic_quotes_gpc())
{
   $your_text = stripslashes($your_text);
}

现在您可以正常处理 $your_text 变量了.

Now you can process $your_text variable normally.

更新:

魔术引述在此解释.对于编写良好的代码,禁用它通常没有坏处.

Magic quotes are exaplained here. For well written code there is normally no harm in disabling it.

这篇关于“每个引号前的斜线"问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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