quotemeta() 函数在字符串中某些预定义的字符前添加反斜杠。
这些预定义字符是:
quotemeta(string)
提示:该函数可用于转义拥有特殊意义的字符,比如 SQL 中的 ( )、[ ] 以及 *。
<?php $str = "Hello world. (can you hear me?)"; echo quotemeta($str); ?>
输出:
Hello world\. \(can you hear me\?\)