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

Function to filter HTML code under PHP_PHP tutorial

WBOY
Release: 2016-07-21 15:54:08
Original
1000 people have browsed it

/*----------------------
过滤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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template