& Lt ;? Phpif ($ _ POST) {// you can convert the file content to an array using the following two methods:/* $ fconfile_get_contents (& quot ;. /filter.txt & quot;); $ filter_wordexplode (& quot; \ n & quot;, $ fcon); */$ filter_wordfile (& quot ;. /filt
If ($ _ POST)
{
// You can convert the file content to an array:
/*
$ 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 "script" alert ('the content you entered contains illegal content. please try again! '); Script ";
Echo "back ";
Exit;
}
}
Echo "the content you entered is:". $ str;
}
?>
Test whether the filter is effective:
From: blog of adamboy