导航:首页 > 净水问答 > php过滤embed

php过滤embed

发布时间:2021-02-04 07:10:42

1. 请问用PHP如何过滤空格内置函数或者正则表达式都可以

你是头尾空格吗?
用trim函数
如果是其他位置用str_replace(" ","","$array");
str_replace(find,replace,string,count)
参数 描述
find 必需。规定要查找的值内。
replace 必需。规定替容换 find 中的值的值。
string 必需。规定被搜索的字符串。
count 可选。一个变量,对替换数进行计数。

2. 如何在PHP中成功的过滤危险HTML的代码

//php批量过滤post,get敏感数据
if(get_magic_quotes_gpc()){
$_GET=stripslashes_array($_GET);
$_POST=stripslashes_array($_POST);
}

functionstripslashes_array(&$array){
while(list($key,$var)=each($array)){
if($key!='argc'&&$key!='argv'&&(strtoupper($key)!=$key||''.intval($key)=="$key")){
if(is_string($var)){
$array[$key]=stripslashes($var);
}
if(is_array($var)){
$array[$key]=stripslashes_array($var);
}
}
}
return$array;
}
//--------------------------

//替换HTML尾标签,为过滤服务
//--------------------------
functionlib_replace_end_tag($str)
{
if(empty($str))returnfalse;
$str=htmlspecialchars($str);
$str=str_replace('/',"",$str);
$str=str_replace("\","",$str);
$str=str_replace("&gt","",$str);
$str=str_replace("&lt","",$str);
$str=str_replace("<SCRIPT>","",$str);
$str=str_replace("</SCRIPT>","",$str);
$str=str_replace("<script>","",$str);
$str=str_replace("</script>","",$str);
$str=str_replace("select","select",$str);
$str=str_replace("join","join",$str);
$str=str_replace("union","union",$str);
$str=str_replace("where","where",$str);
$str=str_replace("insert","insert",$str);
$str=str_replace("delete","delete",$str);
$str=str_replace("update","update",$str);
$str=str_replace("like","like",$str);
$str=str_replace("drop","drop",$str);
$str=str_replace("create","create",$str);
$str=str_replace("modify","modify",$str);
$str=str_replace("rename","rename",$str);
$str=str_replace("alter","alter",$str);
$str=str_replace("cas","cast",$str);
$str=str_replace("&","&",$str);
$str=str_replace(">",">",$str);
$str=str_replace("<","<",$str);
$str=str_replace("",chr(32),$str);
$str=str_replace("",chr(9),$str);
$str=str_replace("",chr(9),$str);
$str=str_replace("&",chr(34),$str);
$str=str_replace("'",chr(39),$str);
$str=str_replace("<br/>",chr(13),$str);
$str=str_replace("''","'",$str);
$str=str_replace("css","'",$str);
$str=str_replace("CSS","'",$str);

return$str;

}

3. 用php过滤html部分标签

$str=preg_replace("/\s+/", " ", $str); //过滤多余回车
$str=preg_replace("/<[ ]+/si","<",$str); //过滤<__("<"号后面带空格)

$str=preg_replace("/<\!--.*?-->/si","",$str); //注释
$str=preg_replace("/<(\!.*?)>/si","",$str); //过滤DOCTYPE
$str=preg_replace("/<(\/?html.*?)>/si","",$str); //过滤html标签
$str=preg_replace("/<(\/?head.*?)>/si","",$str); //过滤head标签
$str=preg_replace("/<(\/?meta.*?)>/si","",$str); //过滤meta标签
$str=preg_replace("/<(\/?body.*?)>/si","",$str); //过滤body标签
$str=preg_replace("/<(\/?link.*?)>/si","",$str); //过滤link标签
$str=preg_replace("/<(\/?form.*?)>/si","",$str); //过滤form标签
$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签

$str=preg_replace("/<(applet.*?)>(.*?)<(\/applet.*?)>/si","",$str); //过滤applet标签
$str=preg_replace("/<(\/?applet.*?)>/si","",$str); //过滤applet标签

$str=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$str); //过滤style标签
$str=preg_replace("/<(\/?style.*?)>/si","",$str); //过滤style标签

$str=preg_replace("/<(title.*?)>(.*?)<(\/title.*?)>/si","",$str); //过滤title标签
$str=preg_replace("/<(\/?title.*?)>/si","",$str); //过滤title标签

$str=preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si","",$str); //过滤object标签
$str=preg_replace("/<(\/?objec.*?)>/si","",$str); //过滤object标签

$str=preg_replace("/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si","",$str); //过滤noframes标签
$str=preg_replace("/<(\/?noframes.*?)>/si","",$str); //过滤noframes标签

$str=preg_replace("/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si","",$str); //过滤frame标签
$str=preg_replace("/<(\/?i?frame.*?)>/si","",$str); //过滤frame标签

$str=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$str); //过滤script标签
$str=preg_replace("/<(\/?script.*?)>/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标签,如javAsCript:alert(

清除空格,换行

function DeleteHtml($str)
{
$str = trim($str);
$str = strip_tags($str,"");
$str = ereg_replace("\t","",$str);
$str = ereg_replace("\r\n","",$str);
$str = ereg_replace("\r","",$str);
$str = ereg_replace("\n","",$str);
$str = ereg_replace(" "," ",$str);
return trim($str);
}

过滤HTML属性

1,过滤所有html标签的正则表达式:

复制代码 代码如下:

</?[^>]+>

//过滤所有html标签的属性的正则表达式:

$html = preg_replace("/<([a-zA-Z]+)[^>]*>/","<\\1>",$html);

3,过滤部分html标签的正则表达式的排除式(比如排除<p>,即不过滤<p>):

复制代码 代码如下:

</?[^pP/>]+>

4,过滤部分html标签的正则表达式的枚举式(比如需要过滤<a><p><b>等):

复制代码 代码如下:

</?[aApPbB][^>]*>

5,过滤部分html标签的属性的正则表达式的排除式(比如排除alt属性,即不过滤alt属性):

复制代码 代码如下:

\s(?!alt)[a-zA-Z]+=[^\s]*

6,过滤部分html标签的属性的正则表达式的枚举式(比如alt属性):

复制代码 代码如下:

(\s)alt=[^\s]*

4. php文章如何过滤链接代码。

PHP中过滤指定标签,只能用正则替换,如专:

<?php
$str='测试<b>文本属</b>ab<a href=" http://www.abc.com/aa/bb/cc.jpg">测试链接</a>测试文本cd';
echo( preg_replace("#<(/?a.*?)>#si",'',$str) );
?>

5. php过滤指定字符的函数

explode — 使用一个字符串分割另一个字符串

array explode ( string $delimiter , string $string [, int $limit ] )

此函数返回由字符串组成的数组,每个元素都是 string 的一个子串内,它容们被字符串 delimiter 作为边界点分割出来。

<?php
//示例1
$pizza="";
$pieces=explode("",$pizza);
echo$pieces[0];//piece1
echo$pieces[1];//piece2

//示例2
$data="foo:*:1023:1000::/home/foo:/bin/sh";
list($user,$pass,$uid,$gid,$gecos,$home,$shell)=explode(":",$data);
echo$user;//foo
echo$pass;//*

?>

6. php文件输出如何过滤掉html,代码如下

<b>asasasas</b>这个html标签是加粗标签,如果你想在浏览器上显示的是版加粗的asasasas就直接输出
<?php
echo "<b>asasasas</b>";

?>

如果你想输权出的<b>asasasas</b>这个字符串的话呢
<?php

echo htmlspecialchars("<b>asasasas</b>");

?>

7. php过滤多余html标签的代码!

php过滤多余html标签的代码!
nction filterhtml($str)
{
$str=stripslashes($str);

$str=preg_replace("/\s+/", ' ', $str); //过滤多余回车
$str=preg_replace("/[ ]+/si",'',$str); //过滤__(""号后面带空格)

$str=preg_replace("/\!--.*?-->/si",'',$str); //注释
$str=preg_replace("/(\!.*?)>/si",'',$str); //过滤DOCTYPE
$str=preg_replace("/(\/?html.*?)>/si",'',$str); //过滤html标签
$str=preg_replace("/(\/?head.*?)>/si",'',$str); //过滤head标签
$str=preg_replace("/(\/?meta.*?)>/si",'',$str); //过滤meta标签
$str=preg_replace("/(\/?body.*?)>/si",'',$str); //过滤body标签
$str=preg_replace("/(\/?link.*?)>/si",'',$str); //过滤link标签
$str=preg_replace("/(\/?form.*?)>/si",'',$str); //过滤form标签
$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签

$str=preg_replace("/(applet.*?)>(.*?)(\/applet.*?)>/si",'',$str); //过滤applet标签
$str=preg_replace("/(\/?applet.*?)>/si",'',$str); //过滤applet标签

$str=preg_replace("/(style.*?)>(.*?)(\/style.*?)>/si",'',$str); //过滤style标签
$str=preg_replace("/(\/?style.*?)>/si",'',$str); //过滤style标签

$str=preg_replace("/(title.*?)>(.*?)(\/title.*?)>/si",'',$str); //过滤title标签
$str=preg_replace("/(\/?title.*?)>/si",'',$str); //过滤title标签

$str=preg_replace("/(object.*?)>(.*?)(\/object.*?)>/si",'',$str); //过滤object标签
$str=preg_replace("/(\/?objec.*?)>/si",'',$str); //过滤object标签

$str=preg_replace("/(noframes.*?)>(.*?)(\/nofr......年年顺景则源广 岁岁平安福寿多 吉星高照

8. php 过滤掉html标签及标签内的所有内容

方法一:使用strip_tags()函数
strip_tags() 函数剥去字符串中的 HTML、XML 以及PHP的标签。
使用内案例:
$string = "<p>这里是容潘旭博客</p>"
$newStr = strip_tags($string);
echo $newStr;

方法二:使用str_replace()函数
str_replace() 函数以其他字符替换字符串中的一些字符(区分大小写)
使用案例:
$string = "<p>这里是潘旭博客</p>";
$newStr = str_replace(array("<p>","</p>"),array("",""));
echo $newStr;

另外还有一种是通过正则的方法,请参考:https://panxu.net/article/8385.html

9. php 过滤掉超链接,及超链连内的网页代码

用正则表达式过滤掉所有HTML代码
过滤所有html标签的正则表达式:
</?[^>]+>

10. php过滤标签如何实现,求高手指导

正则表达式:[.*?]

替换为空

完整的php程序如下:

<?php

$str='[backcolor=#ffffff][color=#333333][font=宋体,tahoma,arial]呵呵1233我是简介[/font][/color][/backcolor]';

$str=preg_replace('#[.*?]#','',$str);

echo$str;

?>

运行结果:

呵呵1233我是简介

阅读全文

与php过滤embed相关的资料

热点内容
温度对纳滤的影响 浏览:651
制药超纯水仪多少钱 浏览:873
济南明新蒸馏水销售部怎么样 浏览:844
玻璃鱼缸上的水垢用什么清理 浏览:526
松下电热壶柠檬酸除垢剂 浏览:364
超滤鱼缸养水器什么牌子的好 浏览:716
南宁市三塘污水处理厂在哪里 浏览:450
一吨氢氟酸废水需要几吨石灰中和 浏览:734
森森12米下过滤水族箱怎么样 浏览:32
暖瓶除垢小妙招 浏览:425
净水器Ro膜75H什么意思 浏览:180
涂料树脂类是指 浏览:42
净水设备ro膜更换图解 浏览:510
污水处理站职业卫生警示告知牌 浏览:718
饮水机的水嘴口上的盖子怎么拆开 浏览:208
宝马空调滤芯怎么样 浏览:43
水处理中空纤维膜产量 浏览:938
下过滤用不用加增氧 浏览:428
企业污水计量器多少钱 浏览:24
恒温壶为什么会有水垢 浏览:907