您的位置:首页 > Web前端 > HTML

php下过滤HTML代码的函数

2007-12-10 15:14 951 查看

具体如下所示:

/*----------------------
过滤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("&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代码的函数,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php 过滤 html 函数