PHP code example of yankewei / laravel-sensitive

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

    

yankewei / laravel-sensitive example snippets


'providers' => [
    //...
    Yankewei\LaravelSensitive\SensitiveServiceProvider::class,
],


'aliases' => [
    //...
    'Sensitive' => Yankewei\LaravelSensitive\Facades\Sensitive::class,
],

...
// $app->withEloquent();

$app->register(Yankewei\LaravelSensitive\SensitiveServiceProvider::class);
...

$interference = ['&', '*'];
$filename = './words.txt'; //每个敏感词独占一行
Sensitive::interference($interference); //添加干扰因子
Sensitive::addwords($filename); //需要过滤的敏感词
$txt = "我说的日本册,滚&蛋不是。。。";
$words = Sensitive::filter($txt);
dd($words);
"我说的**册,***不是。。。"