According to customer requirements, they can manually set and filter some keywords that should not appear in the background, so I wrote the following code, character filtering program
Untitled Document
if($_POST){
$Words = isset($_POST['fiter_words'])?$_POST['fiter_words']:'';
$sql = "Update gx_filter set filter_words='$Words' where id=1";
mysql_query($sql) or die(mysql_error());
echo "<script>alert('设置成功');location='filter.php';</script>";
}
?>
这是在设置过滤字符界面了,下面我们来看看是如何判断并过滤那些我们客户规定不允许出现的字符吧.
function filter_words($str){
$sql = "Select * from gx_filter where id=1 limit 1";
$result = mysql_query($sql);
$rs = mysql_fetch_array($result);
$array = explode('|',$rs['filter_words']);
if( is_array($array) ){
$array_length = sizeof($array);
for($i=0;$i< $array_length; $i++){
$str = @str_replace($array[$i],'',$str);
}
}
return $str;
}
Read the characters that the customer wants to filter from the database, and then process them as above.
Application: For original reprints on this site, please indicate www.111cn.cn/phper/php.html
http://www.bkjia.com/PHPjc/630428.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630428.htmlTechArticleAccording to customer requirements, they can manually set and filter some keywords that should not appear in the background, so I wrote Here is the code below, character filter program! DOCTYPE html PUBLIC -//...
Statement:
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