php过滤字符串函数

 
更多

分享一个php过滤字符串函数,具体代码如下:

function StripHTML($string){
	$pattern=array ("'<script[^>]*?>.*?</script>'si", "'<style[^>]*?>.*?</style>'si",  "'<[\/\!]*?[^<>]*?>'si",  "'([\r\n])[\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 ($pattern, $replace, $str);
}
打赏

本文固定链接: https://www.cxy163.net/archives/4294 | 绝缘体

该日志由 绝缘体.. 于 2013年05月23日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: php过滤字符串函数 | 绝缘体
关键字: , , , ,

php过滤字符串函数:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter