时间:2020-10-15 23:15:35 | 栏目:PHP代码 | 点击:次
具体如下所示:
/*---------------------- 过滤HTML代码的函数 -----------------------*/ function htmlEncode($string) { $string=trim($string); $string=str_replace("&","&",$string); $string=str_replace("'","'",$string); $string=str_replace("&amp;","&",$string); $string=str_replace("&quot;",""",$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; }