PHP简单字符串过滤方法示例
2016-09-04 00:00
821 查看
本文实例讲述了PHP简单字符串过滤方法。分享给大家供大家参考,具体如下:
效果图如下:
更多关于PHP相关内容感兴趣的读者可查看本站专题:《php安全过滤技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php操作office文档技巧总结(包括word,excel,access,ppt)》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
php字符串过滤与替换小结
PHP字符串中特殊符号的过滤方法介绍
浅析php过滤html字符串,防止SQL注入的方法
PHP字符过滤函数去除字符串最后一个逗号(rtrim)
几个有用的php字符串过滤,转换函数代码
PHP对表单提交特殊字符的过滤和处理方法汇总
php完全过滤HTML,JS,CSS等标签
php正则过滤html标签、空格、换行符的代码(附说明)
比较好用的PHP防注入漏洞过滤函数代码
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no"> <title>PHP字符串的过滤方法</title> </head> <body> <?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).']结束'; ?> </body> </html>
效果图如下:
更多关于PHP相关内容感兴趣的读者可查看本站专题:《php安全过滤技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php操作office文档技巧总结(包括word,excel,access,ppt)》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
您可能感兴趣的文章:
php实现过滤字符串中的中文和数字实例php字符串过滤与替换小结
PHP字符串中特殊符号的过滤方法介绍
浅析php过滤html字符串,防止SQL注入的方法
PHP字符过滤函数去除字符串最后一个逗号(rtrim)
几个有用的php字符串过滤,转换函数代码
PHP对表单提交特殊字符的过滤和处理方法汇总
php完全过滤HTML,JS,CSS等标签
php正则过滤html标签、空格、换行符的代码(附说明)
比较好用的PHP防注入漏洞过滤函数代码
相关文章推荐
- PHP简单字符串过滤方法示例
- php简单随机字符串生成方法示例
- PHP基于CURL发送JSON格式字符串的方法示例
- Python简单实现两个任意字符串乘积的方法示例
- PHP工厂模式简单实现方法示例
- PHP使用正则表达式实现过滤非法字符串功能示例
- PHP字符串中特殊符号的过滤方法介绍
- PHP简单获取上月、本月、近15天、近30天的方法示例
- php简单判断两个字符串是否相等的方法
- PHP字符串处理的10个简单方法
- PHP字符串处理的10个简单方法
- 处理PHP字符串的10个简单方法
- php数据过滤函数与方法示例【转载】
- php简单实现多字节字符串翻转的方法
- PHP生成指定随机字符串的简单实现方法
- 一个简单不过却很非常实用的PHP加密字符串方法
- PHP生成静态HTML页面最简单方法示例
- php简单统计字符串单词数量的方法
- php简单统计字符串单词数量的方法
- php简单判断两个字符串是否相等的方法