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

WBOY
Release: 2016-07-29 08:46:07
Original
3511 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template