Home  >  Article  >  Backend Development  >  preg_match函数

preg_match函数

WBOY
WBOYOriginal
2016-06-23 14:05:341121browse

$pattern="/\ $subject="www.baidu.com";
if(preg_match_all($pattern, $subject,$arr))
echo '匹配成功';
    echo '

';   <br>    var_dump($arr);  <br>     echo '
';
?>






结果为什么是
匹配成功

array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(2) "




为什么不是 


回复讨论(解决方案)

$pattern="/\<x/i";$subject="<x>www.baidu.com</a>";if(preg_match_all($pattern, $subject,$arr))echo '匹配成功';    echo '<xmp>';    var_dump($arr);    echo '</xmp>';
匹配成功
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(2) "   }
}

谢谢,原来是被转义了呀

PHP code
?



1234567

$pattern="/\www.baidu.com"; if(preg_match_all($pattern, $subject,$arr)) echo '匹配成功';     echo '

';     var_dump($arr);     echo '';匹配成功
……
版主能否给详解下,XMP是什么,为什么用XMP就可正常输出了?或者给个链接读下。

Statement:
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