Php outputs double quotation marks & quot; and single quotation marks''

Source: Internet
Author: User

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.
Copy codeThe 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
Copy codeThe Code is as follows:
$ Str = "output double quotation marks \"";
Echo $ str;
// Output double quotation marks"

Output single quotes and double quotes
Copy codeThe Code is as follows:
<? Php
$ 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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.