php下过滤HTML代码的函数
发布时间:2016-12-29 来源:查字典编辑
摘要:/*----------------------过滤HTML代码的函数-----------------------*/functionht...
/*----------------------
过滤HTML代码的函数
-----------------------*/
functionhtmlEncode($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("<","<",$string);
$string=str_replace("<","<",$string);
$string=str_replace(">",">",$string);
$string=str_replace(">",">",$string);
$string=str_replace(" ","",$string);
$string=nl2br($string);
return$string;
}