Home >Backend Development >PHP Tutorial >addcslashes() function in PHP
The addcslashes() function returns the string with blackslashes.
Note − The addcslashes() function is case-sensitive
addcslashes(str, characters)
str − The string to be escaped
characters − The character or character range to be escaped
addcslashes() function returns a backslash before the specified character String.
The following is an example−
Real-time demonstration
<?php $str = addcslashes("First World!","W"); echo($str); ?>
The following is the output−
First \World!
Let’s see another example−
Demonstration
<?php $str = addcslashes("First World!","a..r"); echo($str); ?>
Here is the output−
F\i\rst W\o\r\l\d!
The above is the detailed content of addcslashes() function in PHP. For more information, please follow other related articles on the PHP Chinese website!