Home > Backend Development > PHP Tutorial > 关于字符串用单引号和双引号的有关问题

关于字符串用单引号和双引号的有关问题

WBOY
Release: 2016-06-13 12:55:43
Original
800 people have browsed it

关于字符串用单引号和双引号的问题
$pattern_title ='/

(.*?)/iU';//定义一个正则表达式,获取某网页的标题<br> $result=file_get_contents($url);<br> preg_match_all($pattern_title,$result,$title);<br> 问题是,单引号中,不是只能转移'\'和'''么,怎么还要在'/'前加个'\' <div class="tag "> <br><font color="#FF8000">------解决方案--------------------</font><br>写成这样就不用了<br> '#<title>(.*?)#iU'
明白吗?不转义的话,三个分隔符,你让php怎么识别?
------解决方案--------------------
凡是会产生歧义的都要转义
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template