Home  >  Article  >  Backend Development  >  html code function to filter HTML code under php

html code function to filter HTML code under php

WBOY
WBOYOriginal
2016-07-29 08:37:15904browse

/*----------------------
过滤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;
}

以上就介绍了html代码 php下过滤HTML代码的函数,包括了html代码方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

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