PHP的默认设置作用是清除特定的名叫strip_tags的html标识,这在一些场所十分有效。

条型标识

(PHP 3 >= 3.0.8,PHP 4,PHP 5)

脱离标识—从字符串数组中脱离HTML和PHP标识

string strip_tags(字符串数组字符串数组[,字符串数组容许的_tags])

缺陷:

该涵数只有保存需要的html标识,即主要参数字符串数组allowable _ tags。

此涵数的主要参数allowable _ tags的别的主要用途。

strip_tags($source,");除掉html标识。

strip_tags($source, ‘’); 保存字符串数组中的div,img,em标签。strip _ tags($ source ' ');在字符串数组中保存div,img,em标识。

假如你要删掉html的特定标识。那麼这些效果就不可以满足需求了。因此我就用了这一涵数。

/**

*删掉特殊标识。

*/

function strip_only_tags($str,$tags,$ strip content = FALSE){ 0

$ content = ";

if(!is _ array($ tags)){ 0

$tags = (strpos($str,' > ')!==假的?发生爆炸(str_replace('|\s[^>]*>)'.)$內容。#is ',",$ str);

}

回到$ str

}

主要参数叙述

$str — 就是指必须过虑的一段字符串数组,例如div,p,em,img等html标识。$ str-指要进行过滤的字符串数组,如div,p,em,img和别的html标识。

$tags — 就是指要想清除特定的html标识,例如a,img,p等。$ tags-表明您要想清除特定的html标识,如a,img,p等。

$ strip content = FALSE—删掉标识中的內容,比如删掉全部连接。初始值为False,即不删掉标识中的內容。

表明

$ target = strip _ only _ tags($ source,array('a ',' em ',' b '));

删掉$source字符串数组中的A,em和B标识。

$source='”WelcomeThis a example fromlixiphp!$source= '这也是来源于lixiphp的一个事例!

$ target = strip _ only _ tags($ source,array('a ',' em '));

//总体目标結果

//”WelcomeThis a example from!//这也是来源于的一个事例!

:左边;"

评论(0条)

刀客源码 游客评论