PHP code example of text_filter / badword

1. Go to this page and download the library: Download text_filter/badword 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/ */

    

text_filter / badword example snippets


use TextFilter\Badword\Badword;


$config = [
    'host'=>'127.0.0.1',
    'port'=>'6379',
    'password'=>'',
    'select'=>0,
    'expire'=>3600,
];
$filter = new Badword($config);
//$filter->loadData(['枪手','电击枪']);
$filter->setDictFile('./file.txt');
$filter->loadDataFromFile(true);
//$filter->match_badword("枪手",0);
$filter->filter("枪手",'*', 0);