PHP implements filtering of sensitive words in message messages
A code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Two running results
Three Code Analysis
When the user submits the message, the program will use the regular expression Preg_mctch () function to compare the message with the sensitive words stored in the array, and to verify whether the message submitted by the user contains sensitive words. If the message contains a sensitive word, then the message will pop up, otherwise the message message is published successfully.
The "/I" in the Preg_match () function refers to the case of letters that do not differentiate between sensitive vocabulary comparisons.
The above is the PHP implementation of filter message information in the content of sensitive words, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!
Related articles:
An efficient filter method for sensitive words (PHP)
Using PHP extension trie_filter to do Chinese sensitive word filtering
PHP sensitive word filtering uses third-party extensions Trie_filter