Home >Backend Development >PHP Tutorial > 加了个<就无法匹配到结果了

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

WBOY
WBOYOriginal
2016-06-13 11:56:16761browse

求助: 加了个

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

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


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

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

为什么加了个
------解决方案--------------------
你在浏览器中看一下源文件就知道了

 被浏览器解释为 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