//去除HTML标记

php函数

2008-12-16 00:56


function Text2Html($txt){
        $txt = str_replace(" "," ",$txt);
        $txt = str_replace("<","&lt;",$txt);
        $txt = str_replace(">","&gt;",$txt);
        $txt = preg_replace("/[\r\n]{1,}/isU","<br/>\r\n",$txt);
        return $txt;
}

//清除HTML标记
function ClearHtml($str){
        $str = str_replace('<','&lt;',$str);
        $str = str_replac?e('>','&gt;',$str);
        return $str;
}