PHP code with a slash before a special character. For more information, see. The quotemeta () function adds a backslash before some predefined characters in the string.
PHP code with a slash before a special character. For more information, see. The quotemeta () function adds a backslash before some predefined characters in the string.
The Code is as follows:
$ Zongzi = "asdfasdf (asdfasdf? Asfdadsf )";
Echo $ zongzi = quotemeta ($ zongzi );
Echo"
";
$ Zongzi = stripslashes ($ zongzi );
Echo $ zongzi;
?>
Definition and usage
The quotemeta () function adds a backslash before some predefined characters in the string.
The predefined characters are:
Period (.)
Backslash (\)
Plus sign (+)
Asterisk (*)
Question mark (?)
Square brackets ([])
Escape Character (^)
Dollar sign ($)
Parentheses (())
Syntax
Quotemeta (string)
Tips and comments
Tip: this function can be used to escape characters with special meanings, such as (), [], and * in SQL *.
The Code is as follows:
$ Str = "Hello world. (can you hear me ?) ";
Echo quotemeta ($ str );
?>
Output:
Hello world \. \ (can you hear me \? \)