当前位置:Gxlcms > PHP教程 > php下过滤HTML代码的函数_PHP教程

php下过滤HTML代码的函数_PHP教程

时间:2021-07-01 10:21:17 帮助过:7人阅读

/*----------------------
过滤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("<","<",$string);
$string=str_replace("<","<",$string);
$string=str_replace(">",">",$string);
$string=str_replace(">",">",$string);
$string=str_replace(" "," ",$string);
$string=nl2br($string);
return $string;
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318561.htmlTechArticle/*---------------------- 过滤HTML代码的函数 -----------------------*/ functionhtmlEncode($string){ $string=trim($string); $string=str_replace("amp;",$string); $string=str_rep...

人气教程排行