php下过滤HTML代码的函数

2015-01-24信息快讯网
/*----------------------
过滤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;
}
©2014-2024 dbsqp.com