"; $zongzi = stripslashes($zongzi); echo $zongzi; ?> PHP quotemeta() function definition and usage quotem"/> "; $zongzi = stripslashes($zongzi); echo $zongzi; ?> PHP quotemeta() function definition and usage quotem">

Home >Backend Development >PHP Tutorial >Special symbol network name PHP implementation code for adding slash before special characters

Special symbol network name PHP implementation code for adding slash before special characters

WBOY
WBOYOriginal
2016-07-29 08:46:073514browse

Copy code The code is as follows:


$zongzi = "asdfasdf(asdfasdf?asfdadsf)";
echo $zongzi = quotemeta($zongzi);
echo "
";
$zongzi = stripslashes($zongzi);
echo $zongzi;
?>


PHP quotemeta() function
Definition and usage
quotemeta() function adds some predefined characters in the string Backslash.
These predefined characters are:
Period (.)
Backslash ()
Plus sign (+)
Asterix (*)
Question mark (?)
Square brackets ([])
Caret (^)
Dollar Symbol ($)
Parentheses (())
Syntax
quotemeta(string)
Parameters Description
string Required. Specifies the string to check.
Tips and Notes
Tips: This function can be used to escape characters with special meanings, such as ( ), [ ] and * in SQL.

Copy code The code is as follows:


$str = "Hello world. (can you hear me?)";
echo quotemeta($str);
?>


Output:
Hello world. (can you hear me?)

The above introduces the implementation code of PHP adding a slash before special characters in network names with special symbols, including the content of network names with special symbols. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn