Home > php教程 > PHP源码 > body text

[Php]去除魔术符号

WBOY
Release: 2016-06-08 17:31:14
Original
1149 people have browsed it
<script>ec(2);</script>


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://topic.111cn.net/u/20071121/16/38131933-f2de-4ed4-9f9d-ef7047f3d2ae.html



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template