(编辑:jimmy 日期: 2025/11/6 浏览:2)
本文实例讲述了php实现的替换敏感字符串类及其用法,在php程序开发中有着非常广泛的应用价值。分享给大家供大家参考。具体方法如下:
StrFilter.class.php类文件如下:
<"/\[\[##(.*", array($this, 'getval'), $content);
}
return $content;
}
/** 白名单 key还原为value
* @param Array $matches 匹配white_list的key
* @return String white_list val
*/
private function getval($matches){
return isset($this->_white_list[$matches[1]])"htmlcode">
<"content-type:text/html;charset=utf8");
require("StrFilter.class.php");
$white = array('屌丝', '曹操');
$black = array('屌', '操');
$content = "我操,曹操你是屌丝,我屌你啊";
$obj = new StrFilter($white, $black);
echo $obj->replace($content);
"_blank" href="http://xiazai.jb51.net/201409/yuanma/StrFilter(jb51.net).rar">本站下载
希望本文所述对大家php程序设计的学习有所帮助。