Home > Article > Backend Development > php mysql escape special character function
This article introduces the common functions for escaping special characters in PHP mysql programming. Learn how to implement PHP escape characters. Friends in need can refer to it.
In php mysql programming, escape special characters: One is: mysql_escape_string One is: addslashes The difference between mysql_escape_string and addslashes is mysql_escape_string always converts "'" to "'" And addslashes Convert "'" to """ when magic_quotes_sybase=on Convert "'" to "'" when magic_quotes_sybase=off php provides some functions to make your query statements meet your requirements, such as mysql_escape_string Quotes a string and returns a result that can be used in an SQL statement as a suitably escaped data value. The string is returned surrounded by single quotes, and every occurrence of a single quote ("'"), backslash (""), ASCII NUL, and Control-Z in the string is preceded by that character. Add a backslash. If the argument is NULL, the result value is the word "NULL" without 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. I don't know if MySQL itself has such an escaping function, not those APIs. How to escape special characters in url links Detailed explanation of php special character escaping Example of php regular expression escape characters Commonly used escape character functions in PHP PHP function to escape regular expression characters php code to implement anti-injection and form submission value escaping Examples of character escaping methods in mysql statements Notes on php character escaping |