Php double quotation marks and single quotation marks
Source: Internet
Author: User
Variables in the literal in the middle of a single quotation mark are not executed, and variables in the middle of a double quotation mark can be executed. Therefore, the efficiency of output characters in single quotation marks is much higher than that in double quotation marks without variables. In php programming, double quotation marks "and single quotation marks" are strings and characters. how can we output them? let's look at a simple example of single double quotation marks output.
On the homepage, let's look at several methods for outputting double quotation marks.
Method 1.
The code is as follows:
$ Str = 'I want to output double quotation marks "';
Echo $ str;
The result is: I want to output double quotation marks"
Method 2
The code is as follows:
$ Str = "output double quotation marks \"";
Echo $ str;
// Output double quotation marks"
Output single quotes and double quotes
The code is as follows:
$ Str = "output single quotes '";
$ Str1 = 'output single quotes \'';
Echo $ str;
?>
Variables in the literal in the middle of a single quotation mark are not executed, and variables in the middle of a double quotation mark can be executed. Therefore, the efficiency of output characters in single quotation marks is much higher than that in double quotation marks without variables.
For special characters, you can use the escape character.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.