Php special character escape functions

Source: Internet
Author: User
Tags php form
Php special character escape functions
This article describes the usage of functions related to special character escaping in php and describes how php can process special characters. For more information, see.

Mysql and php come with many functions that can handle character issues. Below are some frequently used functions. ps: Since php6 does not support magic_quotes_gpc at the beginning, the following things are assumed to be in the condition of magic_quotes_gpc = off (I don't know what new things will happen to php6 ....)

Mysql_real_escape_string () definition: function escape special characters in strings used in SQL statements. Syntax: mysql_real_escape_string (string, connection) Description: This function escapes special characters in string and considers the connected character set. Therefore, it can be safely used for mysql_query (). Because the instance code is too long, the function explanation link w3school phpnet is provided.

Addslashes () definition: the addslashes () function adds a backslash before a specified predefined character. Syntax: addslashes (string) Note: By default, the magic_quotes_gpc command of php is on, and addslashes () is automatically run for all get, post, and cookie data (). Do not use addslashes () for strings that have been escaped by magic_quotes_gpc, because this causes double-layer escape. In this case, you can use the get_magic_quotes_gpc () function for detection. Because the instance code is too long, the function explanation link w3school phpnet function stripslashes () removes the backslash character. (Used to interpret characters to be filtered)

Mb_convert_encoding () php internal code conversion function version (php 4> = 4.0.6, php 5) This function can convert various encodings related to phpnet

Iconv () php internal code conversion function, same as above because of the bug in iconv () converting gb2312, so it is necessary to deal with php filtering special character practical function php form submission special character filtering method html special character filtering php class url link special character escaping method php special character escaping explanation php filter parameter special character php instance: example of special character processing functions

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.