Many programmers think that in PHP, single and double quotes are the same, in fact, it depends on how to use, in some ways they are the same, but there are some aspects of them are very different, today's small series to tell you what the difference.
1, in general, the two are general. But if the double quotes are written inside the variable, the parse operation is performed, and the single quote does not parse, how does this say? Let's give an example.
Let's see it now!
2, the implementation of the efficiency is not the same, single quotes faster than the execution speed of double quotes, if it is the same large program, this aspect or should pay attention to optimization, after all, PHP belongs to the interpretation of the language. So if there's only a pure string inside, with a single quote (speed), there's something else inside (like a variable) that's more flexible with a double.
PHP double quotes small Hidden trouble
Many of the syntax features of PHP can give an attacker an opportunity, for example, PHP detects variables in double quotes.
Execute the following code:
function test ()
{
echo "abc";
}
echo "${@test ()}";
or
echo ${@phpinfo ()};
The principle is as follows:
$a = ' B ';
$b = ' a ';
echo $ $a; A
The above makes use of PHP variable variables, double quotes {} can parse the variable content characteristics within double quotes create a little trouble. Do you understand? These misunderstandings and small hidden trouble programmers should pay more attention in peacetime.