php安全过滤字符串函数
分享一个php过滤字符串函数,具体代码如下:
function StripHTML($string){<br />$pattern=array ("'<script[^>]*?>.*?</script>'si", "'<style[^>]*?>.*?</style>'si", "'<[/!]*?[^<>]*?>'si", "'([ ])[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");<br />$replace=array ('', '', "\1", '', "&", "<", ">", ' ', chr(161), chr(162), chr(163), chr(169), "chr(\1)");<br />return preg_replace ($pattern, $replace, $str);<br />}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号