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.