Home >Backend Development >PHP Tutorial >A simple PHP content filtering example_PHP tutorial

A simple PHP content filtering example_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:46:29828browse

if($_POST)

{

//Two ways to get the file content and convert it into 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 re-enter!');</script>";

echo "return";

exit;

}

}

echo "The content you entered is:".$str;

}

?>

Test whether filtering is effective:

Excerpted from: adamboy’s blog

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478591.htmlTechArticle?php if($_POST) { //Two ways to get the file content and convert it into an array: /* $fcon = file_get_contents(./filter.txt); $filter_word = explode(n,$fcon); */ $filter_word = file(./filter.txt)...
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