Home>Article>Backend Development> PHP implements filtering sensitive words in message messages
PHP implements filtering sensitive words in message messages
One code
检测留言信息的敏感词
Two running results
Three code analysis
When the user submits a message, the program will use the regular expression preg_mctch() function to compare the message information with the sensitive words stored in the array to check whether the message submitted by the user contains Sensitive words. If the message contains sensitive words, a prompt message will pop up, otherwise the message information will be published successfully.
The "/i" in the preg_match() function means that letters are not case-sensitive when comparing sensitive words.
The above is the content of PHP's implementation of filtering sensitive words in message messages. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!
Related articles:
An efficient sensitive word filtering method (PHP)
Use PHP extension trie_filter to filter Chinese sensitive words
php sensitive word filtering uses a third-party extension trie_filter