php下过滤HTML代码的函数

  作者:bea

/*---------------------- 过滤HTML代码的函数 -----------------------*/ functionhtmlEncode($string){ $string=trim($string); $string=str_replace("&","&",$string); $string=str_replace(",",$string); $string=str_replace("&","&",$stri
/*----------------------

过滤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;

}


有用  |  无用

猜你喜欢