在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1、扩展安装 composer require lustre/php-dfa-sensitive
2、推荐的敏感词库 https://codeload.github.com/jkiss/sensitive-words/zip/refs/heads/master 3、使用: 把下载好的词库放到项目本地 直接上代码: use DfaFilter\SensitiveHelper; public static function checkSensitiveWords($words) { $route = __DIR__. '/../extends/Sensitive_words.txt'; $word = file_get_contents($route); $sensitiveWords = explode(",",$word); $handle = SensitiveHelper::init()->setTree($sensitiveWords);//构建敏感词库树 $isLegal = $handle->islegal($words);//是否有敏感词 if($isLegal) { $words = $handle->replace($words, '***');//敏感词替换成*** } return $words; }
参考地址:https://packagist.org/packages/lustre/php-dfa-sensitive |
2022-08-15
2022-08-30
2022-08-17
2022-11-06
2022-08-17
请发表评论