Differences between htmlspecialchars and addslashes and et_magic_quotes_gpc htmlspecialchars and
Addslashes and
Et_magic_quotes_gpc
There seems to be no difference between these three things. I don't know how to deal with the relationship between them.
Reply to discussion (solution)
Htmlspecialchars converts html objects to html objects, and occasionally converts html objects to object storage before they are stored in the database (generally rich text editing content)
Addslashes escapes special characters. generally, special characters are escaped during database query to prevent SQL injection.
Get_magic_quotes_gpc: determines whether magic_quotes_gpc is enabled (if enabled, php will automatically run addslashes on GET, POST, and COOKIE data) to prevent your second escape
The htmlspecialchars () function converts some predefined characters into HTML objects.
The predefined characters are:
& (And number) become &
"(Double quotation marks)"
'(Single quotes)'
<(Less than) becomes <
> (Greater than) become>
The addslashes () function adds a backslash before the specified predefined character.
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.
Et_magic_quotes_gpc, which should be
Get_magic_quotes_gpc ():
View magic_quotes_gpc value. 0 = Close. 1 = open
Htmlspecialchars has nothing to do with the last two methods.
If get_magic_quotes_gpc is 1, it indicates that the data in GET/POST has been executed by addslashes.
If it is 0, it indicates that addslashes has not been executed, and the user needs to execute addslashes to escape