- echo Strip_tags ($STR);
Copy Code2, keep only A label, you just need to The string is written to the second argument of Strip_tags.
- Echo strip_tags ($str, "
");
Copy Code3, to keep With the. Multiple labels, you only need to separate multiple labels with a space and write to the second parameter of Strip_tags.
- Echo strip_tags ($str, "
");
Copy Code4, keep all tags, just escape with addslashes (), Stripslashes (), Htmlspecialchars (), Htmlentities (), NL2BR () and other functions. Addslashes (), stripslashes () is generally used when entering the database and out of the library, so as to avoid the variables to store similar quotes in the keywords, so that the original content of the part is recognized as an identifier by the database to execute, it will cause errors. The Htmlspecialchars () function is used only to escape a small amount of HTML, &, double quotes, greater than and less than. Does not convert all of the ASCII conversions that are set to HTML Htmlentities () This function is a bit like the Htmlspecialchars () function, but this function will convert all string characters to the special character set string of HTML. However, after the conversion, reading the source code of the Web page, especially the Chinese characters in the source code of the page, will be displayed when browsing is not normal, this should be noted. You may be interested in the article: PHP two ways to remove HTML tags PHP filter HTML tags function strip_tags usage examples (graphic) PHP Delete HTML tags three ways to share PHP delete HTML tags and HTML tags in the code PHP The difference between strip_tags and htmlspecialchars to remove HTML tags PHP removes the HTML tag's function from the HTML tag in the contents of the code to remove HTML tags in PHP code PHP regular filter HTML tags, spaces, Code examples such as line breaks PHP remove HTML tags get input plain text document strip_tagsphp make HTML tag auto complement closed function code PHP implementation HTML tag Auto complement code thinkphp HTML template Tag use method |