Home  >  Article  >  Backend Development  >  Function to filter HTML code under PHP_PHP tutorial

Function to filter HTML code under PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:54:08964browse

/*----------------------
过滤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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn