Php form submission special character filtering method-php Tutorial

Source: Internet
Author: User
Tags php form
Php form submission special character filtering method
This article describes how to filter Special characters when submitting data in php forms. learn how php filters special characters and what character filtering functions are available. For more information, see.

Php form submission special character processing method, mainly used in htmlspecialchars/addslashes/stripslashes/strip_tags/mysql_real_escape_string and other functions.

1. descriptions of php function names related to special character processing htmlspecialchars converts single and double quotation marks, greater than and less than signs into html format & convert to & "convert to"'' <转成<> Conversion to> htmlentities () all characters are converted to html format. in addition to the above htmlspecialchars characters, the two-byte characters are also displayed as encoding. Addslashes single double quotation marks, backslash, and null plus backslash escape characters changed include single quotation marks ('), double quotation marks ("), backslash (\), and null characters. Stripslashes removes the backslash character from the string. If there are two backslash lines in a row, remove one and leave one. If there is only one backslash, remove it directly. Quotemeta adds a reference symbol to include. \ + *? [^] ($) And other characters are preceded by the backslash "\" symbol. Nl2br () converts a line break

Strip_tags remove html and php tags remove any html and php tags in the string, including the contents between Mark blocking. Note: if the html and php tags of the string are incorrect, an error is returned. Special character escape \ x00 \ n \ r space \ '"\ x1a in mysql_real_escape_string escape SQL string, which is very effective for processing multi-byte characters. Mysql_real_escape_string determines the character set, and mysql_escape_string does not need to be considered. Special character escaping methods for html special character filtering php-type url links php special character escaping explanation php filter parameters special characters anti-injection php filter methods for illegal and special strings php instance: the example of a special character processing function replaces the php code of special characters in ultra-long text

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.