Home > Backend Development > PHP Tutorial > The difference between PHP single quotes and double quotes

The difference between PHP single quotes and double quotes

WBOY
Release: 2016-07-29 09:00:05
Original
1214 people have browsed it

PHP 单引号双引号的区别
1、转移字符

单引号

<code><span><?php</span><span>$str</span> = <span>'\',\\,\n,\t,\r,...'</span>;
<span>echo</span><span>$str</span>;
<span>?></span>
输出结果
<span>',\,\n,\t,\r,...</span></code>
Copy after login

双引号

<code><span><?php</span><span>$str</span> = <span>"\",\\,\n,\t,\r,..."</span>;
<span>echo</span><span>$str</span>;
<span>?></span>
输出结果:
<span>",\, ,  , ,...</span></code>
Copy after login

2、变量解析
双引号可以解析变量,单引号不可以解析变量

<code><span><?php</span><span>$a</span> = <span>10</span>;
<span>echo</span><span>'a的值是$a'</span>;
<span>echo</span><span>'<br />'</span><span>echo</span><span>"a的值是$a"</span>;
<span>?></span>
输出结果:
a的值是<span>$a</span>
a的值是<span>10</span></code>
Copy after login

3、执行速度
单引号的执行速度比双引号的执行速度快

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了PHP 单引号双引号的区别,包括了方面的内容,希望对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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template