数据分析师2017-09-30 23:01:30
preg_quote I don’t understand very well, isn’t it converting the delimiter into other characters? -PHP Chinese website Q&A-preg_quote I don’t understand very well. Isn’t it converting the delimiter into other characters? -PHP Chinese website Q&A
Please watch and learn.
阿神2016-12-20 09:41:49
preg_quote() 需要参数 str 并向其中 每个正则表达式语法中的字符前增加一个反斜线。 这通常用于你有一些运行时字符串 需要作为正则表达式进行匹配的时候。
正则表达式特殊字符有: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
eg:
<?php $keywords = '$40 for a g3/400' ; $keywords = preg_quote ( $keywords , '/' ); echo $keywords ; // 返回 \$40 for a g3\/400 ?>