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

html code function to filter HTML code under php

WBOY
Release: 2016-07-29 08:37:15
Original
908 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;
}

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

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