Wednesday, February 2, 2011

addcslashes

Syntax:

addcslashes(string,characters) ;

Example:

'<'?php $str = "Hello, my name is jack siva."; echo addcslashes($str,'m'); echo addcslashes($str,'K'); ?>

Output:

Hello, \my name is jack siva.
Hello, my name is jac\k siva.

Example: Add backslashes to a range of characters in a string

'<'?php echo addcslashes($str,'a..z'); echo addcslashes($str,'a..h'); ?>

Output:

H\e\l\l\o, \m\y \n\a\m\e \i\s \j\a\c\k \s\i\v\a. (only small letters, should not be added in front of capital letters).
H\ello, my n\am\e is j\a\ck siv\a.

No comments:

Post a Comment