Current Location: Home> Function Categories> addslashes

addslashes

Escape strings using backslash
Name:addslashes
Category:String
Programming Language:php
One-line Description:Returns a string that adds a backslash before the predefined characters.

Definition and usage

addslashes() function returns a string that adds a backslash before the predefined characters.

The predefined characters are:

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

Tip: This function can be used to prepare strings for strings stored in the database and database query statements.

Note: By default, PHP automatically runs addslashes() on all GET, POST, and COOKIE data. So you should not use addslashes() for escaped strings, as this will result in double-layer escape. In this case, you can use the function get_magic_quotes_gpc() to detect it.

grammar

 addslashes ( string )
parameter describe
string Required. Specifies the string to be escaped.
Similar Functions
Popular Articles