PHP清除html格式的代码
程序员文章站
2022-03-21 20:08:24
...
$descclear = str_replace("\r","",$descclear);//过滤换行 $descclear = str_replace("\n","",$descclear);//过滤换行 $descclear = str_replace("\t","",$descclear);//过滤换行 $descclear = str_replace("\r\n","",$descclear);//过滤换行 $descclear = preg_replace("/\s+/", " ", $descclear);//过滤多余回车 $descclear = preg_replace("//si","",$descclear); //过滤html注释 $descclear = preg_replace("//si","",$descclear); //过滤DOCTYPE $descclear = preg_replace("//si","",$descclear); //过滤html标签 $descclear = preg_replace("//si","",$descclear); //过滤head标签 $descclear = preg_replace("//si","",$descclear); //过滤meta标签 $descclear = preg_replace("//si","",$descclear); //过滤body标签 $descclear = preg_replace("//si","",$descclear); //过滤link标签 $descclear = preg_replace("//si","",$descclear); //过滤form标签 $descclear = preg_replace("/cookie/si","COOKIE",$descclear); //过滤COOKIE标签 $descclear = preg_replace("/(.*?)/si","",$descclear); //过滤applet标签 $descclear = preg_replace("//si","",$descclear); //过滤applet标签 $descclear = preg_replace("/(.*?)/si","",$descclear); //过滤style标签 $descclear = preg_replace("//si","",$descclear); //过滤style标签 $descclear = preg_replace("/(.*?)/si","",$descclear); //过滤title标签 $descclear = preg_replace("//si","",$descclear); //过滤title标签 $descclear = preg_replace("/(.*?)/si","",$descclear); //过滤object标签 $descclear = preg_replace("//si","",$descclear); //过滤object标签 $descclear = preg_replace("/(.*?)/si","",$descclear); //过滤noframes标签 $descclear = preg_replace("//si","",$descclear); //过滤noframes标签 $descclear = preg_replace("/(.*?)/si","",$descclear); //过滤frame标签 $descclear = preg_replace("//si","",$descclear); //过滤frame标签 $descclear = preg_replace("/(.*?)/si","",$descclear); //过滤script标签 $descclear = preg_replace("//si","",$descclear); //过滤script标签 $descclear = preg_replace("/javascript/si","Javascript",$descclear); //过滤script标签 $descclear = preg_replace("/vbscript/si","Vbscript",$descclear); //过滤script标签 $descclear = preg_replace("/on([a-z]+)\s*=/si","On\\1=",$descclear); //过滤script标签 $descclear = preg_replace("//si","&#",$descclear); //过滤script标签,如javAsCript:alert(); //使用正则替换 $pat = "/]*?)>/isU"; $descclear = preg_replace($pat,"",$descclear);
上一篇: php 文章分页效果代码
下一篇: PHP根据图片色界在不同位置加水印