A simple summary of the difference between single and double quotation marks in a PHP string there are double quotes in a double quote string in a string in the Java string.

Source: Internet
Author: User
Today, a friend asked, said the difference, by the way review.

Single and double quotation marks are different:

    • The fields inside the double quotation mark are interpreted by the compiler and then output as HTML code.
    • "The single quotation mark does not explain, the direct output."
    • Single quotation marks are resolved more quickly than double quotes.
    • Single quotes support \ Escape characters, and double quotes support more escape characters.

$hello = 3;echo "Hello is $hello"; Print Result: Hello is 3 echo ' Hello is $hello '; Print Result: Hello is $hello echo "Hello is $hello \ n"; Print Result: Hello is 2 (simultaneous newline) echo ' Hello is $hello \ n '; Print Result: Hello is $hello \ n

Ps:
Today I saw a foreigner mentioning the single quotation mark of PHP, which mentions something interesting, excerpt from the following:
which says PHP extension Vulcan Logic disassembler, you can see the PHP generated intermediate code,
The first is:

Will change to:

ECHO    

and

It becomes

ECHO    

, is the same
If it is

The opcode generated by PHP is

INIT STRING ~0 2 add_string  ~0 ~0 ' This ' 3 add_string  ~0 ~0 ' 4 add_string  ~0 ~0 ' is ' 5 add_string ~0  ~0 ' 6 add_string  ~0 ~0 ' a ' 7 add_string  ~0 ~0 ' 8 add_var    ~0 ~0!0 9 ECHO      

and

will become

CONCAT    ~0 ' This is a '!0 2 ECHO      

Can see, the speed is much faster, with. Connect the words

The above describes the simple generalization of PHP's string of single and double quotation marks, including the double quotation marks, the content of the string, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.