Home > Backend Development > PHP Tutorial > php中单引号和双引号混合使用的有关问题

php中单引号和双引号混合使用的有关问题

WBOY
Release: 2016-06-13 12:54:57
Original
796 people have browsed it

php中单引号和双引号混合使用的问题
请教大侠,在PHP中如何正确表示字符串:"abc'defg"hijklmn"opq'rst"以及字符串'abc"defg'hijklmn'opq"rst'


------解决方案--------------------
配对就行了,你可以举例说明。。
------解决方案--------------------
$X="old test";
$str1="THIS IS AN $X";
echo $str1;
$str2='THIS IS AN $X';
echo $str2;
------解决方案--------------------
1、字符串要用引号括起
2、被单引号括起的串中的单引号要转义
3、被双引号括起的串中的双引号要转义
------解决方案--------------------
$str='"abc\'defg"hijklmn"opq\'rst"';<br />
$str2='\'abc"defg\'hijklmn\'opq"rst\'';<br />
echo $str.":".$str2;
Copy after login
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template