In fact, in the previous PHP100 video tutorial, I have said that the difference between single and double quotation marks and efficiency problems, but still many friends understand is not very clear, always thought that the single quotation marks and double quotation marks in PHP is interoperable, until one day, found that single and double quotation marks in the wrong time to study. So let's talk about their differences today and hope that we don't get confused about it.
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."
It can be seen literally that single quotes are faster than double quotes.
For example: Shangri-La Casino
$ABC = ' My name is tome ';
echo $ABC//Result: My name is Tom
Echo ' $ABC '//Result: $ABC
echo "$ABC"//Result: My name is Tom
Especially when using MySQL statements, the use of double and single quotes is confusing for novices, here, for example, to illustrate.
Suppose a constant is used in a query condition, for example:
SELECT * from abc_table where user_name= ' abc ';
SQL statements can be written as:
SQLSTR = "SELECT * from abc_table where user _name= ' abc '";
Suppose a variable is used in a query condition, for example:
$user _name = $_request[' user_name '); String variables
Or
$user =array ("name" = $_request[' user_name ', ' age ' =>$_request[' age '];//array variable
SQL statements can be written as:
SQLSTR = "SELECT * from abc_table where user_name = '". $user _name. " ‘ ";
SQLSTR = "SELECT * from abc_table where user_name = '". $user [' name ']. " ‘ ";
Compare:
Sqlstr= "SELECT * from abc_table where user_name = ' abc '";
Sqlstr= "SELECT * from abc_table where user_name = '". $user _name. " ‘ ";
Sqlstr= "SELECT * from abc_table where user_name = '". $user [' name ']. " ‘ ";
Sqlstr can be decomposed into the following 3 parts:
1: "SELECT * FROM table where user_name = '"//fixed SQL statement
2: $user//variable
3: "'"
The "." Connection between the half-and-part strings