PHP addslashes() Function

PHP addslashes() function is used to add backslashes before the characters that need to be escaped. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).


string addslashes(str);

addslashes() Function Parameter

str :Required parameter. The string to be escaped.

addslashes() Function Return Value

Return Value :Returns the escaped string.

addslashes() Function Example

echo addslashes("Who Tom's Hero?");

echo addslashes('What does "honey" mean?');