PHP uses preg_replace and preg_match to filter sensitive words
Code 1:
Copy to ClipboardQuoted content:
[www.bkjia.com]
$badstring="tmd|damn|TNND|her motherfucker";
$string="What did you tmd say, her motherfucker is not a human being";
echo preg_replace(" /$badstring/i",'',$string);
?>
Code 2:
Copy to ClipboardQuoted content:
[www.bkjia.com]
$badkey = "sensitive word|sensitive word B|sensitive word C";
$string = "I do not contain sensitive words, I want to publish";
if(preg_match("/$badkey/i",$string)){
echo "Sorry, it contains sensitive characters and is not allowed to be published";
}else {
//do something...
echo "Bangkejia Tips: You can use www.bkjia.com";
}
?>
http://www.bkjia.com/PHPjc/363924.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/363924.htmlTechArticlePHP uses preg_replace and preg_match to filter sensitive words Code 1: Copy to Clipboard Quoted content: [www.veryhuo.com ] ?php $badstring=tmd|Damn|TNND|Her mother-in-law; $string=What did you tmd say...