quotemeta() 函数在字符串中某些预定义的字符前添加反斜杠。
预定义的字符:
提示:该函数可用于转义拥有特殊意义的字符,比如 SQL 中的 ( )、[ ] 以及 * 。
注释:该函数是二进制安全的。
返回值: | 返回引用元字符的字符串。 |
PHP 版本: | 4+ |
在多个预定义字符前添加反斜杠:
</>code
- <?php
- $str1 = "1 + 1 = 2";
- $str2 = "1 * 1 = 1";
- $str3 = "Could you borrow me 5$?";
- $str4 = "Are you not e&";
- $str5 = "The caret [ ^ ] Looks like a hat!";
- echo quotemeta($str1)."<br>";
- echo quotemeta($str2)."<br>";
- echo quotemeta($str3)."<br>";
- echo quotemeta($str4)."<br>";
- echo quotemeta($str5)."<br>";
- ?>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号