Home > php教程 > php手册 > body text

php 输出双引号"与单引号''的方法

WBOY
Release: 2016-06-06 20:33:48
Original
1426 people have browsed it

单引号中间的字面里面的变量不会执行,双引号中间的变量可以执行,所以在没有变量的情况下,用单引号输出字符效率要比用双引号高很多。

在php 编程中双引号"与单引号'是字符串与字符表现形式,那么我们要输出它怎么做呢,下面我们就来看个简单的输出单双引号的实例吧。

首页我们来看输出双引号的几种方法
方法一.
代码如下:
$str ='我要输出双引号"';
echo $str;

结果为:我要输出双引号"

方法二
代码如下:
$str ="输出双引号\"";
echo $str;
//结果输出双引号"

输出单引号与双引号
代码如下:
$str ="输出单引号'";
$str1='输出单引号\'';
echo $str;
?>


单引号中间的字面里面的变量不会执行,双引号中间的变量可以执行,所以在没有变量的情况下,用单引号输出字符效率要比用双引号高很多。

对于特殊字符,大家可以用转移字符"\"即可.
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!