導航:首頁 > 凈水問答 > 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相關的資料

熱點內容
什麼牌的純凈水蒸臉好 瀏覽:7
機油濾芯歐菲怎麼樣 瀏覽:394
廢水廢氣處理程序 瀏覽:381
超濾膜纖維斷了 瀏覽:225
飲水機送電跳閘什麼原因 瀏覽:2
有除垢地暖管嗎 瀏覽:577
樹脂材料怎麼維修 瀏覽:444
怎麼才能把污水變清水視頻 瀏覽:676
污水管需要提升泵嗎 瀏覽:918
蒸餾水與健身 瀏覽:956
ro膜脫除氧氣 瀏覽:657
水垢和壺有關系嗎 瀏覽:306
污水中怎麼能產生氨氣 瀏覽:34
凈化器異響是怎麼回事 瀏覽:63
污水提升泵屬於清單里什麼泵 瀏覽:86
陽新城東污水處理廠 瀏覽:608
浙江污水管道清淤怎麼操作 瀏覽:845
純水泥漿有什麼作用 瀏覽:244
溫度對納濾的影響 瀏覽:651
制葯超純水儀多少錢 瀏覽:873