php 如何清空字符串中的HTML标签过滤Html

要过滤字符串中所有的html标签有两种方法一种是我们自己写一个函数,用正则过滤,一个是用php自带函数strip_tags哦。
function clear_html_label($html)
{
$search = array (“‘<script[^>]*?>.*?</script>’si”, “‘<[/!]*?[^<>]*?>’si”, “‘([rn])[s]+’”, “‘&(quot|#34);’i”, “‘&(amp|#38);’i”, “‘&(lt|#60);’i”, “‘&(gt|#62);’i”, “‘&(nbsp|#160);’i”, “‘&(iexcl|#161);’i”, “‘&(cent|#162);’i”, “‘&(pound|#163);’i”, “‘&(copy|#169);’i”, “‘&#(d+);’e”);
$replace = array (“”, “”, “1″, “”", “&”, “<”, “>”, ” “, chr(161), chr(162), chr(163), chr(169), “chr(1)”);
return preg_replace($search, $replace, $html);
}
//实例应用
$string =’aaa<br /> <script>fdsafsa’;
echo clear_html_label($string);//aaa fdsafsa
//利用php自带函数strip_tags();
echo strip_tags($string);//aaa fdsafsa
总结,
上面二个函数得出的结果完全相同,一个是用户自定义的过滤所有html函数,一个是php内置函数,但在效绿上来说php的strip_tags()函数,肯定要高很多。至少为什么我就不说多了。
php 如何清空字符串中的HTML标签

要过滤字符串中所有的html标签有两种方法一种是我们自己写一个函数,用正则过滤,一个是用php自带函数strip_tags哦。 function clear_html_label($html) {  $search = array (“‘<script[^>]*?>.*?</script>’si”, “‘<[/!]*?[^<>]*?>’si”, “‘([rn])[s]+’”, “‘&(quot|#34);’i”, “‘&(amp|#38);’i”, “‘&(lt|#60);’i”, “‘&(gt|#62);’i”, “‘&(nbsp|#160);’i”, “‘&(iexcl|#161);’i”, “‘&(cent|#162);’i”, “‘&(pound|#163);’i”, “‘&(copy|#169);’i”, “‘&#(d+);’e”);      $replace = array (“”, “”, “1″, “”", “&”, “<”, “>”, ” “, chr(161), chr(162), chr(163), chr(169), “chr(1)”);      return preg_replace($search, $replace, $html); }  //实例应用 $string =’aaa<br /> <script>fdsafsa’; echo clear_html_label($string);//aaa fdsafsa  //利用php自带函数strip_tags(); echo strip_tags($string);//aaa fdsafsa  总结, 上面二个函数得出的结果完全相同,一个是用户自定义的过滤所有html函数,一个是php内置函数,但在效绿上来说php的strip_tags()函数,肯定要高很多。至少为什么我就不说多了。php 如何清空字符串中的HTML标签

YUI宽度不一样、变小问题 -宽度设置,使用 em :当用户改变字体大小时,宽度同时改变

技巧:用 13 像素来平分宽度(保留小数到千分位),而 IE 浏览器用 13.333 。
/* 750 centered, and backward compatibility */
#doc {
width:57.69em;
*width:56.251em;
min-width:750px;
}
No IE: 57.69 = 750 / 13
IE: 56.251 = 750 / 13.333
注:《Setting Page Width with YUI Grids》 一文中提到:IE 下的 em 是宽度除以 13 ,再乘以 .9759 得到。同解于为什么现在的 YUI 源码中 IE 下 750px 的宽度是:56.301em(750 / 13 * 0.9759)。
此算法将在 YUI 的下个版本中换为上面的新算法(IE 浏览器用 13.333 )。

技巧:用 13 像素来平分宽度(保留小数到千分位),而 IE 浏览器用 13.333 。
/* 750 centered, and backward compatibility */#doc {width:57.69em;*width:56.251em;min-width:750px;}
No IE: 57.69 = 750 / 13
IE: 56.251 = 750 / 13.333
注:《Setting Page Width with YUI Grids》 一文中提到:IE 下的 em 是宽度除以 13 ,再乘以 .9759 得到。同解于为什么现在的 YUI 源码中 IE 下 750px 的宽度是:56.301em(750 / 13 * 0.9759)。
此算法将在 YUI 的下个版本中换为上面的新算法(IE 浏览器用 13.333 )。

所以,当你发现你的宽度与 px的值不一致时,可能是由于你设置了body的字体不是13px,将body的font-size设置为13px,即可显示正确。

(全文…)

Web 设计中的中国传统色彩速查表

觉得很全,分享一下,以下为作者iiduce所言“诗词中有:“名花韵在年晴初,雨沁胭脂脸更敷。”,你知道胭脂是什么颜色么?“回眸一笑百媚生,六宫粉 黛无颜色。”中的这个“黛”又是指什么颜色呢?“漆黑一片”里漆黑真的就是完全的黑色吗?在下面这个Web设计中的中国传统色彩速查表,你可以得到准确的 答案。

(全文…)

firefox 下模拟text-overflow:ellipsis

firefox到现在还不支持text-overflow:ellipsis;

用css模拟,还有很多问题,而且也只是在ul,li标签试用了下!

(全文…)

DIV 图片垂直居中

.pic
{
width:160px;
height:160px;
border:solid?1px?#ccc;
text-align:center;
}

.pic?a
{
display:table-cell;
width:160px;
height:160px;
vertical-align:middle;
*display:block;
*font-family:Arial!important;
*font-size:140px;/*约为高度的0.873,160*0.873?约为140*/
*line-height:1;
}
.pic?a?img
{
vertical-align:middle;
max-width:160px;
max-height:160px;
border:0px;
}

(全文…)

纯净Css+html 实现简单进度条效果

<style>
.graph {
position: relative;
width: 200px;
border: 1px solid #B1D632;
padding: 2px;
margin-bottom: .5em;
}
.graph .bar {
display:block;position:relative;
background: #B1D632;
text-align: center;
color: #333;
height: 10px;
line-height: 10px;
}
.graph .bar span { position:absolute;left: 1em; }

</style>

<h3>简单进度条</h3> (全文…)

请问如何过滤HTML标签?

用正则表达式?? /<[^>]*>/?? Replace掉就可以了 (全文…)