Home > php教程 > php手册 > 替换敏感词汇行为扩展!!

替换敏感词汇行为扩展!!

WBOY
Release: 2016-06-07 11:43:11
Original
1481 people have browsed it

前台替换敏感词汇行为扩展
<?php <br /> /**<br>  * Created by PhpStorm.<br>  * User: cony<br>  * Date: 13-11-18<br>  * Time: 下午8:53<br>  */<br> class FilterWordBehavior extends Behavior{<br> <br>     protected $options=array(<br>         'FILTERWORD'=>true,<br>         'KEYWORDS'=>'',<br>         'REPLACEWORD'=>'***'<br>     );<br> <br>     public function run(&$content){<br>         if(C('FILTERWORD.FILTERWORD'))<br>         $content = $this->FilterWordsContent($content);<br>     }<br>     /**<br>      * 模板内容替换<br>      * @access protected<br>      * @param string $content 模板内容<br>      * @return string<br>      */<br>     protected function FilterWordsContent($content) {<br>         $keywordstring=C('FILTERWORD.KEYWORDS');<br>         $keywordarray=explode(',',$keywordstring);<br>         $replaceword=C('FILTERWORD.REPLACEWORD');<br>         $replace=array();<br>         if(is_array($keywordarray)){<br>             foreach($keywordarray as $key=>$value){<br>                 $replace[$value]=$replaceword;<br>             }<br>         }<br>         $content = str_replace(array_keys($replace),array_values($replace),$content);<br>         return $content;<br>     }<br> <br> }代码来源及使用方法:http://www.conist.com/bbs/forum.php?mod=viewthread&tid=12&extra=page%3D1

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template