预览模式: 普通 | 列表

Php检查非法字符函数

 用于过滤某些非法字符。

PHP代码
  1. <?php  
  2. function filterkeywords($keyword){  
  3.     $result=true;  
  4.     $bannedkeywords='http|www.|=|inurl|insert|select|@|site';  
  5.     $str=explode('|',$bannedkeywords);  
  6.     $count=count($str);  
  7.     for($i=0;$i<$count;$i++){  
  8.         if(strpos(strtolower($keyword),$str[$i])>0){  
  9.             $result=false;  
  10.         }  
  11.     }  
  12.     return $result;  
  13. }  
  14. ?>  

原创代码,转载请注明出处,谢谢!

Tags: php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2590

 广告位

↑返回顶部↑