PHP addslashes() Function

PHP addslashes() Function

The addslashed() function in PHP is used to return a string with backslashes in front of predefined characters. This function is only used with some characters which are as follows:

  • single quote (‘)
  • double quote (“)
  • backslash (\)
  • NULL (the NUL byte)

Syntax

Parameter

str(required)– This parameter represents the string to be escaped.

Return 

This function returns a string with backslashes added before characters that need to be escaped.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output