Home  >  Article  >  Backend Development  >  求助: 加了个<就无法匹配到结果了

求助: 加了个<就无法匹配到结果了

WBOY
WBOYOriginal
2016-06-23 13:57:49771browse

$str='adfefdfdf<if codition=("{$name} eq 1")>2014/5/2fafefdfef。';preg_match_all('#if\s+codition=(.*)\s*>#U',$str,$arr);echo '<pre class="brush:php;toolbar:false">';print_r($arr);

没有
Array(    [0] => Array        (            [0] => if codition=("{$name} eq 1")>        )    [1] => Array        (            [0] => ("{$name} eq 1")        ))


$str='adfefdfdf<if codition=("{$name} eq 1")>2014/5/2fafefdfef。';preg_match_all('#<if\s+codition=(.*)\s*>#U',$str,$arr);echo '<pre class="brush:php;toolbar:false">';print_r($arr);

的结果
Array(    [0] => Array        (            [0] =>         )    [1] => Array        (            [0] => ("{$name} eq 1")        ))

为什么加了个


回复讨论(解决方案)

Array(    [0] => Array        (            [0] => <if codition=("{$name} eq 1")>        )    [1] => Array        (            [0] => ("{$name} eq 1")        ))
没有问题!

你在浏览器中看一下源文件就知道了

 被浏览器解释为 html 标记了
用 pre 是阻止不了的,要用 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
Previous article:PHP $_SERVERNext article:请教sql注入问题