This article introduces the PHP MySQL programming special characters of the common functions, learning the implementation of the PHP escape character, the need for a friend reference. In PHP MySQL programming, escape special characters: one is: mysql_escape_string One is: addslashes The difference between mysql_escape_string and addslashes is that Mysql_escape_string always converts "'" to "\" and addslashes Convert "'" to "" when Magic_quotes_sybase=on Convert "'" to "\" when Magic_quotes_sybase=off PHP, it provides some functions to make your query statements conform to your requirements, such as mysql_escape_string References a string and returns a result that can be used as an appropriately escaped data value in an SQL statement. The string is enclosed in quotation marks around the return, and in that string each single quotation mark ("'"), backslash ("\"), ASCII NUL, and Control-z appear where the character is preceded by a backslash. If the argument is null, then the result value is a word "NULL" that is not surrounded by single quotes. The QUOTE function was added in MySQL 4.0.3. When writing data to the database, sometimes the string to be written contains some special characters, such as ', ',/,%, etc., do not know that MySQL itself has no such escape function, not those APIs. Special character escaping method in URL link php special character escape details php regular expression escaped character example PHP common escape character function PHP escape regular expression character function PHP implementation anti-injection and form commit value escaped code the method of escaping the character in the MySQL statement example PHP character escapes considerations |