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

WBOY
Release: 2016-06-23 13:57:49
Original
785 people have browsed it

$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);
Copy after login

没有<得到的结果是
Array(    [0] => Array        (            [0] => if codition=("{$name} eq 1")>        )    [1] => Array        (            [0] => ("{$name} eq 1")        ))
Copy after login


有<
$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);
Copy after login

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

为什么加了个<就无法匹配到结果了呢,<也不是元字符啊,谁能解答下。


回复讨论(解决方案)

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

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

 被浏览器解释为 html 标记了
用 pre 是阻止不了的,要用 xmp 才行

明白了。。。。

Related labels:
lt
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!