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 a backslash before certain predefined characters in a string .
These predefined characters are:
Period (.)
Backslash ()
Plus sign (+)
Asterix (*)
Question mark (?)
Square brackets ([])
Caret (^)
Dollar sign ($)
Parentheses (())
Syntax
quotemeta(string)
参数 |
描述 |
string |
必需。规定要检查的字符串。 |
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?)
http://www.bkjia.com/PHPjc/323994.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323994.htmlTechArticleCopy the code as follows: ?php $zongzi = "asdfasdf(asdfasdf?asfdadsf)"; echo $zongzi = quotemeta ($zongzi); echo "br /"; $zongzi = stripslashes($zongzi); echo $zongzi; ? PHP quotem...