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

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

WBOY
WBOYOriginal
2016-06-13 12:55:43782browse

关于字符串用单引号和双引号的问题
$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怎么识别?
------解决方案--------------------
凡是会产生歧义的都要转义
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: 关于GET获取值为空提示有关问题 Next article: 昨天微博看见有人出了一道题解决方法

Related articles

See more