1. Go to this page and download the library: Download singiu/wordban 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/ */
singiu / wordban example snippets
$sensitive_words = array(
'SB', '傻逼', 'Fuck'
);
use Singiu\WordBan;
$text = 'SB就是傻逼!fuck is a bad word!';
WordBan::load($sensitive_words);
$result = WordBan::escape($text); // escape 方法会将文本中找到的敏感词使用替代词(默认是*)替换掉。
echo $result; // **就是**!**** is a bad word!
// 你也可以改变默认的替换字符,如换成 'x'。
WordBan::setEscapeChar('x');
echo WordBan::escape($text); // xx就是xx!xxxx is a bad word!
use Singiu\WordBan;
$username = $_POST['username'];
$sensitive_words = ['Singiu'];
WordBan::load($sensitive_words);
$bad_words = WordBan::scan($username);
if (count($bad_words) > 0) {
echo '昵称中含有不合适的字符!';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.