zoukankan      html  css  js  c++  java
  • php防注入,表单提交值转义

    在开发时,我们要注意防止sql注入,所以在对表单提交过来的值要做相应的处理,才可以把数据更新到数据库里

    php横扫千军函数。任何值都可以传过来转换

    function quotes($content)    
    {    
        //如果magic_quotes_gpc=Off,那么就开始处理    
        if (!get_magic_quotes_gpc()) {    
            //判断$content是否为数组 
            if (is_array($content)) {    
                //如果$content是数组,那么就处理它的每一个单无    
                foreach ($content as $key=>$value) {    
                    $content[$key] = addslashes($value);    
                }    
            } else {    
                //如果$content不是数组,那么就仅处理一次    
                addslashes($content);    
            }    
        } else {    
            //如果magic_quotes_gpc=On,那么就不处理    
        }    
        //返回$content    
        return $content;  
    

      

    显示的时候要用 stripslashes ()去掉反斜杠

    stripslashes()了,它能把addslashes()处理时自动加上去的(反斜杠)\去掉

  • 相关阅读:
    K好数
    最大最小公倍数
    十六进制转十进制
    利用malloc定义数组
    01字串
    ubuntu 14.04 下jdk和sdk+eclipse 的配置
    Mysql3
    求最大连续子串
    UC笔试
    java实现随机洗牌算法
  • 原文地址:https://www.cnblogs.com/freespider/p/2915815.html
Copyright © 2011-2022 走看看