0

我正在为 php 和 Zend MVC 使用 Doctrine ORM。我有一个mysql数据库。当我插入数据库时​​,它正在转义引号。换句话说,当我进入

<input name="customer_name" value="Test'ed user"> ...

进入我的形式,并分配给一个教义对象并保存。

当我通过 mysql 命令行查看数据库时,我得到

Test\'ed user

有没有办法禁用它或者我必须调用stripslashes()每个变量?

4

2 回答 2

2

magic_quotes_gpc通过查看 php.ini 或运行来检查是否已启用get_magic_quotes_gpc()

如果您有权访问 php.ini,请将其关闭。否则,您需要使用删除脚本中的斜杠stripslashes()

于 2009-11-29T23:27:21.420 回答
1

magic_quotes_gpc您可以通过在页面顶部添加以下内容来完全避免瘟疫:

if(get_magic_quotes_gpc()) {
    if(!function_exists('stripishlashes_all')) {
        function stripslashes_all(&$data) {
            foreach($data as &$_value) {
                if(is_array($_value)) {
                    stripslashes_all($_value);
                }
                else {
                    $_value = stripslashes($_value);
                }
            }
        }
    }
    stripslashes_all($_REQUEST);
}

Very useful when your code is running on a server you don't have complete control over, or if you plan to distribute it.

于 2009-11-30T08:13:09.787 回答