Home > Backend Development > PHP Tutorial > How to output double quotes ' and single quotes ' in php

How to output double quotes ' and single quotes ' in php

WBOY
Release: 2016-07-29 08:42:33
Original
1117 people have browsed it

In PHP programming, double quotes " and single quotes ' are expressions of strings and characters. So how do we output it? Let's take a look at a simple example of outputting single and double quotes.
Let's look at the output on the homepage Several methods of double quotes
Method 1.

Copy code The code is as follows:


$str ='I want to output double quotes"';
echo $str;


The result is: I want to output Double quotes"
Method 2

Copy code The code is as follows:


$str ="Output double quotes"";
echo $str;
//The result outputs double quotes"


Output single quotes and Double quotes

Copy code The code is as follows:


$str ="Output single quotes'";
$str1='Output single quotes'';
echo $str;
?> ;


Variables in literals between single quotes will not be executed, but variables between double quotes can be executed, so when there are no variables, using single quotes to output characters is much more efficient than using double quotes
For special characters. , you can use the transfer character "".

The above introduces the method of outputting double quotes " and single quotes ' in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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