This thought that PHP single-cited differences so simple and basic knowledge should be every phper know, the result is still very many phper not clear, this point I am also very sad, a lesson from the pain, so, we have to completely fix PHP in the single and double-cited differences, in fact very easy.
When PHP parses the double-cited, it will take the initiative to parse the parser once, to the conversion of the string, so assume that the double-argument string has variables, you will be actively using variables to replace, such as the following code:
<?php$xin = "Sinsing"; echo "$xin"; Echo ' $xin ';
The output of the above code is as follows:
Sinsing $xin
The reason is very easy, that is, when we use the double-cited, we will actively be resolved to Sinsing, when we use a single-quote, will be output as is.
In fact, there are no variables, and some escape symbols are parsed in the double-argument, for example, we look at the following code:
<?php$xin = "xin \" Star "echo" $xin "echo" <br/> "; Echo ' $xin ';
I think you should guess what the output is, yes, the output is as follows:
Symplectic "star $xin
Of course, there is a small misunderstanding, do not know whether you know, that is, we can test the following code for example what effect? The code is as follows:
<?php$xin = "Sinsing"; echo "$xin hello";
Assuming the reader feels the output is "Sinsing Hello", it also shows that it has not been practical, in fact its output is as follows:
( ! ) Scream:error suppression ignored for (!) notice:undefined variable:xin Hello in D:\MyApp\wamp\www\api.php to line 3Call stack# Timememoryfunctionlocation10.0021138760{main} (): \api.php:0
By reading the above error message, we know that it turns "Xin Hello" as a variable to parse, obviously this variable is not exist, so, our program out of the bug, then how to change it? In fact, add a space, the modified code such as the following:
<?php$xin = "Sinsing"; echo "$xin hello";
Its output results are as follows:
Hello, Sinsing.
By the way, another point has been forgotten, that is, the use of a single quote will be slightly faster, because it does not have this analytic variable process, the reason is very good understanding it.
Sinsing and you thoroughly interpret the differences between single and double cited