if($_POST)

{

//获取文件内容转为数组两种方法:

/*

$fcon = file_get_contents("./filter.txt");

$filter_word = explode("\n",$fcon);

*/

$filter_word = file("./filter.txt");

//$filter_word = array("test1","test2","test3","test4");

$str = $_POST["mess"];

for($i=0;$i

{

if(preg_match("/".(trim($filter_word[$i]))."/i",$str))

{

echo "";

echo "";

exit;

}

}

echo "您输入的内容是:".$str;

}

?>

测试过滤是否生效:

摘自:adamboy的博客

http://www.bkjia.com/PHPjc/478591.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478591.htmlTechArticle?php if($_POST) { //获取文件内容转为数组两种方法: /* $fcon = file_get_contents(./filter.txt); $filter_word = explode(\n,$fcon); */ $filter_word = file(./filter.txt)...

09-17 14:09