微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP简单字符串过滤方法示例

本文实例讲述了PHP简单字符串过滤方法分享给大家供大家参考,具体如下:

rush:PHP;"> <Meta charset="UTF-8"> <Meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a>字符串的过滤<a href="https://www.jb51.cc/tag/fangfa/" target="_blank" class="keywords">方法</a> PHP function strFilter($str){ //特殊字符的过滤方法 $str = str_replace('`','',$str); $str = str_replace('·',$str); $str = str_replace('~',$str); $str = str_replace('!',$str); $str = str_replace('!',$str); $str = str_replace('@',$str); $str = str_replace('#',$str); $str = str_replace('$',$str); $str = str_replace('¥',$str); $str = str_replace('%',$str); $str = str_replace('^',$str); $str = str_replace('……',$str); $str = str_replace('&',$str); $str = str_replace('*',$str); $str = str_replace('(',$str); $str = str_replace(')',$str); $str = str_replace('(',$str); $str = str_replace(')',$str); $str = str_replace('-',$str); $str = str_replace('_',$str); $str = str_replace('——',$str); $str = str_replace('+',$str); $str = str_replace('=',$str); $str = str_replace('|',$str); $str = str_replace('\\',$str); $str = str_replace('[',$str); $str = str_replace(']',$str); $str = str_replace('【',$str); $str = str_replace('】',$str); $str = str_replace('{',$str); $str = str_replace('}',$str); $str = str_replace(';',$str); $str = str_replace(';',$str); $str = str_replace(':',$str); $str = str_replace(':',$str); $str = str_replace('\'',$str); $str = str_replace('"',$str); $str = str_replace('“',$str); $str = str_replace('”',$str); $str = str_replace(',',$str); $str = str_replace(',',$str); $str = str_replace('<',$str); $str = str_replace('>',$str); $str = str_replace('《',$str); $str = str_replace('》',$str); $str = str_replace('.',$str); $str = str_replace('。',$str); $str = str_replace('/',$str); $str = str_replace('、',$str); $str = str_replace('?',$str); $str = str_replace('?',$str); //防sql防注入代码的过滤方法 $str = str_replace('and',$str); $str = str_replace('execute',$str); $str = str_replace('update',$str); $str = str_replace('count',$str); $str = str_replace('chr',$str); $str = str_replace('mid',$str); $str = str_replace('master',$str); $str = str_replace('truncate',$str); $str = str_replace('char',$str); $str = str_replace('declare',$str); $str = str_replace('select',$str); $str = str_replace('create',$str); $str = str_replace('delete',$str); $str = str_replace('insert',$str); $str = str_replace('or',$str); return trim($str); } $cont = ' ?”?;onestopweb.cn and update //\ as chaoyi 》、 '; echo '开始['.strFilter($cont).']结束'; ?>

效果图如下:

更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》、《》及《

希望本文所述对大家PHP程序设计有所帮助。

原文地址:https://www.jb51.cc/php/19087.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐