- Echo strip_tags ($ str );
2. retain only For a tag, you only need The string is written to the second parameter of strip_tags.
- Echo strip_tags ($ str ,"
");
3. retain And... Multiple tags, separated by spaces, must be written to the second parameter of strip_tags.
- Echo strip_tags ($ str ,"
");
4. keep all tags and only escape functions such as addslashes (), stripslashes (), htmlspecialchars (), htmlentities (), and nl2br. Addslashes () and stripslashes () are generally used when the database is in and out of the warehouse, so as not to store keywords such as quotation marks in the variables. in this case, if a part of the content is recognized as an identifier by the database for execution, an error will occur. The htmlspecialchars () function is only used to escape a small amount of HTML, &, double quotation marks, greater than or less than signs. it is not converted to the ASCII conversion specified in HTML. Htmlentities () this function is a bit like the htmlspecialchars () function, but this function converts all string characters into special character set strings of HTML. However, when reading the source code of a web page, especially the text in the source code of a web page, it will be abnormal during browsing. Articles that you may be interested in: two methods for removing html tags by php: example of how php filters html tags using the strip_tags function (text) php: three methods for deleting html tags: php: code for deleting html tags from html tags and code for deleting html tags from strings: php: differences between strip_tags and htmlspecialchars analysis of removing html tags from string deletion functions by php html tag code extraction html tag php code php regular filter html tags, spaces, line breaks, and other code examples php remove html tags get input plain text document strip_tagsphp make HTML tags automatically closed function code php: how to use html template tags of code thinkPHP to automatically complete Html tags |