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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 11:12:23929browse

关于字符串用单引号和双引号的问题
$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:curl 如何看请求头Next article:[正则表达式]请问怎么"匹配以某字符串结尾或者结束"例如MV&id=17328895840&scm=102和MV&id=17328895840都可以匹配

Related articles

See more