Heim  >  Artikel  >  Backend-Entwicklung  >  php利用正则过滤各种标签,空格,换行符的代码_PHP教程

php利用正则过滤各种标签,空格,换行符的代码_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:31:20974Durchsuche

收集php利用正则过滤各种标签,空格,换行符的代码:

$str=preg_replace("/\s+/", " ", $str); //过滤多余回车
$str=preg_replace("//si","",$str); //注释
$str=preg_replace("//si","",$str); //过滤DOCTYPE
$str=preg_replace("//si","",$str); //过滤html标签
$str=preg_replace("//si","",$str); //过滤head标签
$str=preg_replace("//si","",$str); //过滤meta标签
$str=preg_replace("//si","",$str); //过滤body标签
$str=preg_replace("//si","",$str); //过滤link标签
$str=preg_replace("//si","",$str); //过滤form标签
$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签
$str=preg_replace("/(.*?)/si","",$str); //过滤applet标签
$str=preg_replace("//si","",$str); //过滤applet标签
$str=preg_replace("/(.*?)/si","",$str); //过滤style标签
$str=preg_replace("//si","",$str); //过滤style标签
$str=preg_replace("/(.*?)/si","",$str); //过滤title标签
$str=preg_replace("//si","",$str); //过滤title标签
$str=preg_replace("/(.*?)/si","",$str); //过滤object标签
$str=preg_replace("//si","",$str); //过滤object标签
$str=preg_replace("/(.*?)/si","",$str); //过滤noframes标签
$str=preg_replace("//si","",$str); //过滤noframes标签
$str=preg_replace("/(.*?)/si","",$str); //过滤frame标签
$str=preg_replace("//si","",$str); //过滤frame标签
$str=preg_replace("/(.*?)/si","",$str); //过滤script标签
$str=preg_replace("//si","",$str); //过滤script标签
$str=preg_replace("/javascript/si","Javascript",$str); //过滤script标签
$str=preg_replace("/vbscript/si","Vbscript",$str); //过滤script标签
$str=preg_replace("/on([a-z]+)\s*=/si","On\\1=",$str); //过滤script标签
$str=preg_replace("//si","&#",$str); //过滤script标签

您可能感兴趣的文章

  • PHP压缩html网页代码(清除空格,换行符,制表符,注释标记)
  • php 将字符串中的连续多个空格转换为一个空格
  • css控制英文、中文强制换行与不换行的代码
  • 通用的PHP防注入漏洞攻击的过滤函数代码
  • php利用array_flip实现数组键值交换去除数组重复值
  • Javascript将内容分享到各大社交平台网站的代码总结
  • php如何清除html格式并去除文字中的空格然后截取文字
  • 禁止网页右键、复制、另存为、查看源文件等功能实现网页源代码保护

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/764093.htmlTechArticle收集php利用正则过滤各种标签,空格,换行符的代码: $str=preg_replace("/\s+/", " ", $str); //过滤多余回车$str=preg_replace("/[ ]+/si","",$str); //过滤_...
Stellungnahme:
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