addcslashes() function in php
0 2110
PHP addcslashes() function is used to add backslashes in a string before the characters given by the user. It is an inbuilt function of PHP. This function returns a modified string.
Syntax:
addcslashes($string,$characters);
Note: To add backslashes before some special predefined characters use addslashes() function.
- $string is the input string in which we want to add backslashes.
- $characters are the characters before them we want to add backslashes into the given input string.
Example:
<?php $string="Ram goes to his school every morning."; $caharacters="a,e"; $new_string=addcslashes($string,$caharacters); echo "Old string is : $string <br>"; echo "New string is :$new_string"; ?>
Output:

Share:
Comments
Waiting for your comments