douyi6168 2010-11-28 10:19
浏览 14
已采纳

PHP $ _GET撇号[复制]

Possible Duplicate:
“slash before every quote” problem

Hi, I am trying to use $_GET to send the contents of a text box to another php document. But whenever I try to use single (') or double (") quotes, the text is received as \' or \". When I try to use str_replace, I get a php error. I need to use $_GET instead of $_POST, because I need to be able to bookmark the page.

Here is the code: HTML document:

<form action="result.php" method="get">
<input type="text" name="code" size="70" />
<input type="submit" />
</form>

PHP document:

<?php
echo $_GET["code"];
?>
  • 写回答

2条回答 默认 最新

  • duanlang1531 2010-11-28 10:23
    关注

    Disable Magic Quotes. On top of the page, you can code like this:

    <?php
    if (get_magic_quotes_gpc()) {
        $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
        while (list($key, $val) = each($process)) {
            foreach ($val as $k => $v) {
                unset($process[$key][$k]);
                if (is_array($v)) {
                    $process[$key][stripslashes($k)] = $v;
                    $process[] = &$process[$key][stripslashes($k)];
                } else {
                    $process[$key][stripslashes($k)] = stripslashes($v);
                }
            }
        }
        unset($process);
    }
    ?>
    

    There are better options available. REad here http://www.php.net/manual/en/security.magicquotes.disabling.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错