PHP code example of phpch / dfa-sensitive-word
1. Go to this page and download the library: Download phpch/dfa-sensitive-word library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpch / dfa-sensitive-word example snippets
// 获取感词库文件路径
$wordFilePath = 'tests/words/key2.txt';
$handle = SensitiveWordFilter::init()->setFilePath($wordFilePath)->buildTree();
// 设置缓存后可以避免重复构建铭感词树
$handle = SensitiveWordFilter::init()->setFilePath($wordFilePath)->buildTree(true);
// 删除缓存
$handle->clearCache();