PHP Remove HTML tags--strip_tags and htmlspecialchars differences in detail font: [Increase decrease] Type: Reprint time: 2013-06-26 This article is to remove HTML tags in PHP and strip_ tags and htmlspecialchars the difference between a detailed analysis of the introduction, the need for a friend reference
Strip_tags
Remove the HTML and PHP tags.
Syntax: string strip_tags (String str);
return value: String
Function type: Data processing
Content Description
This function removes any HTML and PHP tag strings contained in the string. If the string of HTML and PHP tags are wrong, for example, less than the symbol, it will also return errors. The function and FGETSS () have the same functions.
Htmlspecialchars
Converts special characters to HTML format.
Syntax: String htmlspecialchars (String string);
return value: String
Function type: Data processing
This function converts special characters to HTML string format (&....;). The most commonly used occasion may be to deal with the message of the customer message version.
& (and) turn into &
"(double quotation marks) to turn"
< (less than) turn into <
> (greater than) turn into >
"(single quote) turn into '
This function converts only the above special characters, and does not convert all of the ASCII conversions that are determined by the HTML.
Copy CodeThe code is as follows:
<?php
$new = Htmlspecialchars ("<a href= ' test ' >Test</a>", ent_quotes);
Echo $new;
?>
PHP Removal HTML Tags--strip_tags and htmlspecialchars The difference between the detailed