PHP Summary of the filtering and processing of special characters for form submission _php tips

Source: Internet
Author: User
Tags html tags

PHP on the form to submit special characters of the processing method to do a summary, mainly related to Htmlspecialchars/addslashes/stripslashes/strip_tags/mysql_real_escape_ Several functions, such as String, are used jointly to communicate with others.

One or several PHP functions related to special character processing

The name of the function

Interpretation

Introduced

Htmlspecialchars

Converts to HTML format with, single double quotes, greater than and less than

& Turn &
"Turn"
' Turn '
< Turn <
> Turn >

Htmlentities ()

All characters are converted to HTML format

In addition to the above Htmlspecialchars characters, also include double-byte characters to display the encoding and so on.




Addslashes

Single double quotes, backslash and null plus backslash escape

The changed characters include single quotation marks ('), double quotes ("), backslash backslash (\), and null character nulls.

Stripslashes

Remove backslash characters

Remove the backslash character from the string. If you have two consecutive backslashes, remove one and leave one. If there is only one backslash, remove it directly.




Quotemeta

Add Reference symbol

Contains the string. \\ + * ? [ ^ ] ($) Precede the character with the backslash "\" symbol.

NL2BR ()

Convert newline characters to


Strip_tags

Remove HTML and PHP tags

Remove any HTML tags and PHP tags from the string, including marking the contents between the blocking. Note If there are errors in the string HTML and PHP tags, an error is returned.

Mysql_real_escape_string

Escape a special character in a SQL string

The escape \x00 \ r \ n space \ ' "\X1A is effective for multibyte character processing. Mysql_real_escape_string will judge the character set, and mysql_escape_string is not to be considered.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.