Home > Backend Development > PHP Tutorial > preg_match函数

preg_match函数

WBOY
Release: 2016-06-23 14:05:34
Original
1135 people have browsed it

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

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






结果为什么是
匹配成功

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>';
Copy after login
匹配成功
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就可正常输出了?或者给个链接读下。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template