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(); www.zzarea.com
echo strip_tags($string);//aaa fdsafsa

/*
总结,
上面二个函数得出的结果完全相同,一个是用户自定义的过滤所有html函数,一个是php内置函数,但在效绿上来说php的strip_tags()函数,肯定要高很多。至少为什么我就不说多了。
*/

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

javascript 字符串转化为整数 什么方法

Integer.parseInt(String)???? or???? parseInt(String?? )

var?? n=parseInt(“123″);
if(isNaN(n))
{
//不能转数字
}

php url字符串截取路径的文件名和扩展名