Today, a friend asked, the next difference, by the way review.
Single quotes differ from double quotes:
- The fields inside the double quotes are interpreted by the compiler and then exported as HTML code.
- ' Single quotes inside without explanation, direct output.
- Single quotes parse more quickly than double quotes.
- Single quotes support \ Escape characters, 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 (line wrap at the same time)
Echo ' Hello is $hello \ n '; Print Result: Hello is $hello \ n
Ps:
today, I saw a foreigner mention the single quotation mark of PHP, which mentions the interesting things, excerpt as follows:
Which said that installed PHP expansion Vulcan Logic disassembler, you can see the middle code generated by PHP,
The first is:
Will turn into:
ECHO ' This is a string '
and
It becomes
ECHO ' This is a string '
, is the same
If it is
echo "This is a $variable";
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 A dd_string ~0 ~0 '
6 add_string ~0 ~0 ' a ' 7 add_string ~0 ~0 ' "
8 add_var ~0 ~0!0
9 ECHO ~0
and
echo "This is a". $variable;
It will become
CONCAT ~0 ' This is a '!0
2 ECHO ~0
You can see, the speed is much faster, use. Connection words