首页 > php代码 > [Php]去除魔术符号

[Php]去除魔术符号

<?php
/**
 * 去除魔术变换 
 */ 
class killMagicQuote
{
    public function Strip_Magic_Slashes($varImp)
    {
        #将数组中所有值进行 函数操作.
        $varImp =  is_array($varImp)? array_map(array($this,''Strip_Magic_Slashes''), $varImp) : stripslashes($varImp);
        return $varImp;
    }
    /**
     * 去除 $_GET $_POST $_REQUEST  内魔术符号.
     */
    public function Magic_Quotes_Off()
    {
        if (get_magic_quotes_gpc())
        {
            $_GET     = $this->Strip_Magic_Slashes($_GET);
            $_POST    = $this->Strip_Magic_Slashes($_POST);
            $_REQUEST = $this->Strip_Magic_Slashes($_REQUEST);
        }
    }
}


 相信很多人都碰到过与magic_quotes有关的问题.

上面给出的代码是我学习别人的(不是抄:)

OpenPNE里的东西(小日本的开源SNS).


本文地址:http://www.phprm.com/code/0af0db6d5db3320f00015966b10c6a57.html

转载随意,但请附上文章地址:-)

标签:none

发表留言