The addcslashes() function : add backslashes in front of the specified characters in a string.
addcslashes ( string $string , string $charlist ) : string
| Parameter Name | Descrption |
|---|---|
| $string | Required, The string to be escaped |
| $charlist | Optional, A list of characters for escaped |
| Cscape Characters | Converted to |
|---|---|
| 0 (NULL) | \0 |
| r (carriage return) | \r |
| n (newline) | \n |
| t (tab) | \t |
| v (vertical tab) | \v |
| f (form feed) | \f |
Returns the escaped string
echo addcslashes("Test String","S");
//Test \String
$string = "addcslashes String Example in PHP";
echo addcslashes($string,'S');
//addcslashes \String Example in PHP
echo addcslashes($string,'s');
//addc\sla\she\s String Example in PHP
Related Functions