PHP addcslashes
The PHP addcslashes function can add a backslash (\) in front of the specified character to make it a escape character. The string filtering before data processing is quite easy to use. addcslashes is similar to addslashes , but addcslashes is more flexible. Because you can decide which characters to add a backslash before, unlike addslashes which can only handle specific characters. In addition, the addcslashes function also has a special function, which can set all characters in a range of English letters as escape characters, and the case of English letters can also be distinguished.
Basic syntax of PHP addcslashes function
String addcslashes( $string, $charlist)
In the grammar, there are two parameters in the parentheses of the addcslashes function. The first parameter $string is the string to be converted, which is required. The second parameter $charlist is used to set which characters to skip, that is A backslash (\) will be added in front of these set characters, and unique character symbols or English alphabetical sequence sections can be set, with different capitalization.
PHP addcslashes function example
$new_string = "Welcome to wibibi.It was a very nice day.";
echo $new_string.'<br>';
echo addcslashes($new_string,'W').'<br>';
echo addcslashes( $new_string,'w').'<br>';
echo addcslashes($new_string,'A..Z').'<br>';
echo addcslashes($new_string,'a..z').'< br>';
echo addcslashes($new_string,'A..z').'<br>';
?>
\Welcome to wibibi.It was a very nice day.
Welcome to \wibibi.It \was a very nice day.
\Welcome to wibibi.\It was a very nice day.
W \e\l\c\o\m\e \t\o \w\i\b\i\b\iI\t \w\a\s \a \v\e\r\y \n\i \c\e \d\a\y.
\W\e\l\c\o\m\e \t\o \w\i\b\i\b\i.\I\t \w\a \s \a \v\e\r\y \n\i\c\e \d\a\y.
Post a Comment
0 Comments