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 |