Heim > Backend-Entwicklung > PHP-Tutorial > html特殊字符过滤php类

html特殊字符过滤php类

WBOY
Freigeben: 2016-07-25 08:53:58
Original
984 Leute haben es durchsucht
[code] class HtmlFilter { /** * 过滤字符串中的特殊字符 * @static * @param $content * @return string */ public static function filterSpacialHtmlChar($content) { if (empty($content)) { return ''; } $content=self::delAllSpace($content); $content=self::replaceHtmlAndJs($content); return strip_tags($content); } /** * 生成摘要 * @static * @param $content * @param $len * @param string $char * @return string */ public static function getSummary($content,$len=100,$char='UTF-8'){ if(empty($content)){ return ''; } if($len>=mb_strlen($content)){ return self::filterSpacialHtmlChar($content); } // bbs.it-home.org return mb_substr(self::filterSpacialHtmlChar($content),0,$len,$char).'...'; } /** * 去掉 $str中的特殊字符 * @static * @param $document * @return mixed|string */ public static function replaceHtmlAndJs($document) { $document = trim($document); if (strlen($document) ","gt","#62","greater-than sign"); $sh[]=array("?","OElig","#338","latin capital ligature OE"); $sh[]=array("?","oelig","#339","latin small ligature oe"); $sh[]=array("?","Scaron","#352","latin capital letter S with caron"); $sh[]=array("?","scaron","#353","latin small letter s with caron"); $sh[]=array("?","Yuml","#376","latin capital letter Y with diaeresis"); $sh[]=array("?","circ","#710","modifier letter circumflex accent"); $sh[]=array('',"tilde","#732","small tilde"); $sh[]=array("?","ensp","#8194","en space"); $sh[]=array("?","emsp","#8195","em space"); $sh1[]=array("?","thinsp","#8201","thin space"); $sh[]=array("–","ndash","#8211","en dash"); $sh[]=array("—","mdash","#8212","em dash"); $sh[]=array("‘","lsquo","#8216","left single quotation mark"); $sh[]=array("’","rsquo","#8217","right single quotation mark"); $sh[]=array("?","sbquo","#8218","single low-9 quotation mark"); $sh[]=array("“","ldquo","#8220","left double quotation mark"); $sh[]=array("”","rdquo","#8221","right double quotation mark"); $sh[]=array("?","bdquo","#8222","double low-9 quotation mark"); $sh[]=array("?","dagger","#8224","dagger"); $sh[]=array("?","Dagger","#8225","double dagger"); $sh[]=array("‰","permil","#8240","per mille sign"); $sh[]=array("?","lsaquo","#8249","single left-pointing angle quotation mark"); $sh[]=array("?","rsaquo","#8250","single right-pointing angle quotation mark"); $sh[]=array("


Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage