php中HtmlEncode和EncodeHtml的编写方式

function HtmlEncode($fString)
{
if($fString!="")
{
$fString = str_replace( '>', '>',$fString);
$fString = str_replace( '<', '&lt;',$fString);
$fString = str_replace( chr(32), '&nbsp;',$fString);
$fString = str_replace( chr(13), ' ',$fString);
$fString = str_replace( chr(10) & chr(10), '<br>',$fString);
$fString = str_replace( chr(10), '<BR>',$fString);
}
return $fString;
}
function EncodeHtml($fString)
{
if($fString!="")
{
$fString = str_replace("&gt;" , ">", $fString);
$fString = str_replace("&lt;", "<", $fString);
$fString = str_replace("&nbsp;",chr(32),$fString);
$fString = str_replace("",chr(13),$fString);
$fString = str_replace("<br>",chr(10) & chr(10),$fString);
$fString = str_replace("<BR>",chr(10),$fString);
}
return $fString;
}
posted @ 2012-06-13 10:32  tokeep  阅读(1505)  评论(0编辑  收藏  举报