``` --- ##"> ``` --- ##" />
Easy Tutorial
❮ Func Array Pos Php Is_Int Function ❯

PHP addcslashes() Function

PHP String Reference Manual

Example

Add backslashes before the character "W":

<?php
$str = addcslashes("Hello World!", "W");
echo($str);
?>

Definition and Usage

The addcslashes() function returns a string with backslashes added before specified characters.

Note: The addcslashes() function is case-sensitive.

Note: Be cautious when applying addcslashes() to 0 (NULL), r (carriage return), n (newline), t (tab), f (form feed), and v (vertical tab). In PHP, \0, \r, \n, \t, \f, and \v are predefined escape sequences.


Syntax

Parameter Description
string Required. Specifies the string to be escaped.
characters Required. Specifies the character or range of characters to be escaped.

Technical Details

Return Value: Returns the escaped string.
PHP Version: 4+
--- ---

More Examples

Example 1

Add backslashes to specific characters in a string:

Example 2

Add backslashes to a range of characters in a string:

❮ Func Array Pos Php Is_Int Function ❯