企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
函数 ```php if (!function_exists('sensitive_words_filter')) { /** * 敏感词过滤 * * @param string * @return string */ function sensitive_words_filter($str) { if (!$str) return ''; //敏感词路径 $file = 'public/static/plug/censorwords/CensorWords'; //引入 $words = file($file); //循环替换 foreach ($words as $word) { $word = str_replace(array("\r\n", "\r", "\n", "/", "<", ">", "=", " "), '', $word); if (!$word) continue; $ret = preg_match("/$word/", $str, $match); if ($ret) { return $match[0]; } } return ''; } } ``` CensorWords文件内容自己定义