/*** 过滤一些脏词汇** $words 脏词汇列表** $replace 要替换成的词汇** 返回替换完的词汇*/function replace_danger_word($content){ ?$words=array(‘妈的‘,‘sb‘,‘我靠‘); ?$replace =‘*‘; ?foreach($words as $key=>$word){ ??$content=str_replace($word,$replace,$content); ?} ?return $content;}/*** 过滤一些js字符** $string 要传入的字符** 返回替换完的词汇*/function stripscript($string){ ?$pregfind=array("/<script.*>.*<\/script>/siU",‘/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i‘); ?$pregreplace=array(‘‘,‘‘,); ?$string=preg_replace($pregfind,$pregreplace,$string); ?return $string; }
php 过滤垃圾代码过滤脏字
原文地址:https://www.cnblogs.com/aid12580/p/10426176.html