PHP function strip_tagshtmlspecialchars function: strip_tags ($ str, $ allow)
Purpose: remove html/xml and php labels.
Parameter: $ allow specifies the exceptional tags, which are not deleted.
World!"); // Output: Hello world! Echo strip_tags ("HelloWorld!",""); // Output: Hello world! // View the html source code: HelloWorld!?>
Note: The fgetss () function has similar functions.
Function: htmlspecialchars (string, quotestyle, character-set)
Purpose: Convert Special characters into html objects.
Note: The conversion special characters include (only these five characters are supported ):
& (And) &
"(Double quotation marks)"
<(Less than) to <
> (Greater than) to>
''(Single quotes)'
Function: htmlentities
Purpose: convert all characters into html objects.
Parameter: character-set can specify the character set. if the converted string contains Chinese characters, you must set the character set to GB2312.
Otherwise, garbled characters will appear in the conversion result.
Function: html_entity_decode
Purpose: restores an html object to a character, which is an inverse function of htmlentities.
Function: htmlspecialchars_decode
Function: restores a predefined html object to a character. it is an inverse function of htmlspecialchars.
Function: addslashes
Purpose: add a backslash before a predefined character.
Note: predefined characters include single quotation marks ('), double quotation marks (''), backslash (\), and NULL.
This function is used to prepare suitable strings for strings stored in the database and database query statements.
If the magic_quotes_gpc parameter of php is on and addslashes is automatically run for all get/post/cookie data, do not use addslashes to avoid double-layer escape;
In this case, use the get_magic_quotes_gpc () function for detection.
Function: stripslashes
Purpose: delete the backslash added by the addslashes () function.
Note: This function is used to clear data retrieved from a database or HTML form.
Function: mysql_real_escape_string
Purpose: Escape special characters in strings used in SQL statements.
The affected characters include:
\ X00 \ n \ r \ '"\ x1a
Return: The escaped string is returned successfully. if the string fails, false is returned.
Note: the difference between this function and htmlspecialchars is that mysql_real_escape_string is used to prevent SQL injection,
Htmlspecialchars converts html to avoid XSS attacks.