Home >Backend Development >PHP Tutorial >Detailed explanation of the difference between php mysql_escape_string and addslashes_PHP tutorial

Detailed explanation of the difference between php mysql_escape_string and addslashes_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:14:21876browse

For a detailed explanation of the difference between php mysql_escape_string and addslashes, you can refer to this article.

The mysql_real_escape_string() function escapes special characters in strings used in SQL statements.

The following characters are affected:

•x00
•n
•r

•'
•"
•x1a
If successful, the function returns the escaped string. If failed, returns false.


The addslashes() function adds a backslash before the specified predefined characters.

These predefined characters are:

•Single quote (')
•Double quotes (")
•Backslash ()
•NULL

Summary of differences
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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629045.htmlTechArticlephp For a detailed explanation of the difference between mysql_escape_string and addslashes, you can refer to this article. The mysql_real_escape_string() function escapes special characters in strings used in SQL statements. The following words...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn