PHP addslashes() function

The addslashes() function returns a string with backslashes.

Syntax

addslashes ( string $string ) : string

Parameters

Parameter Name Descrption
$string Required, A string to be escaped
    These are predefined characters :
  • single quote (')
  • double quote (")
  • backslash (\)
  • NULL

Return Value

Returns the escaped string

addslashes() examples

echo addslashes("It's test string");
//Output :: It\'s test string

Related Functions