PHP explanations of htmlspecialchars, strip_tags, and addslashes. Htmlspecialchars, strip_tags, and addslashes of PHP are common functions in Web application development. today we will detail the usage of these functions: 1. strip_tags: htmlspecialchars, strip_tags, and addslashes of PHP with HTML and PHP removed are common functions in Web application development. today we will detail the usage of these functions:
1. function strip_tags: remove HTML and PHP tags
Note: This function removes any HTML and PHP tag strings contained in the string. If the HTML and PHP tags of a string are incorrect, for example, if a greater symbol is missing, an error is returned. This function and fgetss () have the same functions. Fgetss reads the file from the file and removes the html and php markup.
2. the htmlspecialchars function converts special characters to HTML format.
Specifically, this function converts the following characters:
& (And) &
"(Double quotation marks)"
<(Less than) to <
> (Greater than) to>
3. the htmlentities function converts all the elements into HTML strings.
Maybe you are still sorry that htmlspecialchars can only process four html tags, so now you should not regret it. htmlentities is to convert all characters. It cannot be said to be powerful, but it is of little significance to me.
4. the stripslashes function is a pair with addslashes. addslashes uses a backslash to reference strings, and stripslashes is used to restore the strings referenced by addslashes.
This function is generally a necessary step for processing before database queries. this string is added with a backslash before certain characters for database query statements. These characters are single quotation marks ('), double quotation marks ("), backslash (/), and NUL (NULL ).
Example 1. function strip_tags: remove HTML and PHP...