首页 > 编程 > PHP > 正文

php下过滤HTML代码的函数

2019-11-22 01:35:30
字体:
来源:转载
供稿:网友

具体如下所示:

/*---------------------- 过滤HTML代码的函数 -----------------------*/ function htmlEncode($string) {   $string=trim($string);   $string=str_replace("&","&",$string);   $string=str_replace("'","'",$string);   $string=str_replace("&amp;","&",$string);   $string=str_replace("&quot;",""",$string);   $string=str_replace("/"",""",$string);   $string=str_replace("&lt;","<",$string);   $string=str_replace("<","<",$string);   $string=str_replace("&gt;",">",$string);   $string=str_replace(">",">",$string);   $string=str_replace("&nbsp;"," ",$string);   $string=nl2br($string);   return $string; } 

以上所述是小编给大家介绍的php下过滤HTML代码的函数,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对武林网网站的支持!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表