PHP Special character escaping function

Source: Internet
Author: User
Tags php class php example php form php form submit
This article introduces the use of the relevant functions of special character escaping in PHP, and the method of handling special characters in PHP, and the reference of the friends who need them.

MySQL and PHP come with a lot of functions to handle character problems, here are a few that are often used. PS: Since PHP6 does not support MAGIC_QUOTES_GPC at first, the following things are assumed to be in magic_quotes_gpc=off conditions ( I don't know what new things will come out of php6 ....)

Mysql_real_escape_string () Definition: The function escapes special characters in the string used in the SQL statement. Syntax: mysql_real_escape_string (string,connection) Description: This function escapes special characters in a string and takes into account the current character set of the connection, so it can be used safely for mysql_query (). Because the instance code is too long, the function explanation link is given W3school phpnet

Addslashes () Definition: the Addslashes () function adds a backslash before the specified predefined character. Syntax: addslashes (String) Comment: By default, PHP instruction MAGIC_QUOTES_GPC is on, and automatically runs Addslashes () for all get, post, and cookie data. Do not use Addslashes () for strings that have been MAGIC_QUOTES_GPC escaped, because this results in double-layer escaping. You can use the function GET_MAGIC_QUOTES_GPC () to detect this situation. Because the instance code is too long, the function explanation link w3school phpnet correlation function stripslashes () removes the backslash character. (Used when interpreting filter characters)

Mb_convert_encoding () PHP's internal code conversion function version (PHP 4 >= 4.0.6, PHP 5) This function can convert various encodings to each other related LINKS phpnet

Iconv () PHP Internal code conversion function, as above because Iconv () in the conversion of gb2312 when the bug, So to handle the PHP filter special character utility function php form Submit special character filter method HTML special character filter PHP class URL link special character escape method php special character escape detailed PHP filter parameters special characters anti-injection PHP Methods for filtering illegal and special strings PHP Example: special character handling Function example

  • Related Article

    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.