Re: string functions and manipulations in php Now discuss about addcslashes()
addcslashes() - Returns a string with backslashes in front of the specified characters.
Syntax
addcslashes(string,characters)
Example
$str = "Hello, my name is Kai Jim.";
echo $str."<br />";
echo addcslashes($str,'A..Z')."<br />";
echo addcslashes($str,'a..z')."<br />";
echo addcslashes($str,'a..h');
Output:
Hello, my name is Kai Jim.
\Hello, my name is \Kai \Jim.
H\e\l\l\o, \m\y \n\a\m\e \i\s K\a\i J\i\m.
H\ello, my n\am\e is K\ai Jim.
Note:
Be careful using addcslashes() on 0, r, n and t. In PHP, \0, \r, \n and \t are predefined escape sequences. |