php下过滤html代码的函数 提高程序安全性
2010-03-02 00:00
1036 查看
以下为过滤HTML代码的函数:
php下过滤HTML代码的函数
function ihtmlspecialchars($string) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = ihtmlspecialchars($val); } } else { $string = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/', '&\\1', str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string)); } return $string; }
php下过滤HTML代码的函数
function htmlEncode($string) { $string=trim($string); $string=str_replace("&","&",$string); $string=str_replace("'","'",$string); $string=str_replace("&","&",$string); $string=str_replace(""",""",$string); $string=str_replace("\"",""",$string); $string=str_replace("<","<",$string); $string=str_replace("<","<",$string); $string=str_replace(">",">",$string); $string=str_replace(">",">",$string); $string=str_replace(" "," ",$string); $string=nl2br($string); return $string; }
相关文章推荐
- php下过滤html代码的函数 提高程序安全性
- php下过滤HTML代码的函数
- php下过滤HTML代码的函数
- php 过滤html标签的函数代码
- php下过滤html代码的函数
- PHP 过滤HTML代码空格,回车换行符的函数
- php 过滤html标签的函数代码
- php下过滤HTML代码的函数
- C#过滤所有HTML代码的函数
- PHP 文件系统管理函数与 preg_replace() 函数过滤代码
- C#过滤所有HTML代码的函数
- PHP 清除HTML代码、空格、回车换行符的函数
- php 使用htmlspecialchars() 和strip_tags函数过滤HTML标签的区别
- php 安全过滤函数代码
- 根据指定两个日期计算出这些时间内有多少天是周末 php程序函数代码
- PHP技巧:php过滤危险html代码
- php不同版本htmlspecialchars函数过滤GBK编码时中文为空
- php过滤html(php过滤html函数)
- php HtmlReplace输入过滤安全函数
- PHP htmlspecialchars() 函数实例代码及用法大全