What is {} in the SQL query? $ Sqlstrselect & nbsp; name & nbsp; from & nbsp; user & nbsp; where & nbsp; the code I wrote. what is the role of {} in it? Thank you ~~ ------ Solution ------------------ in the string, {variable} is used to indicate the value of a variable. what is {} in the SQL query?
$ Sqlstr = "select name from user where id = '{$ row [0]}'";
What is the role of {} in the code I wrote?
Thank you ~~
------ Solution --------------------
In the string "", {variable} is used to reference the value of a variable. of course, it can be used normally without adding brackets in most cases, but it is a good habit to add braces.
------ Solution --------------------
The content enclosed by braces "{}" indicates a whole.
Anything that may be ambiguous should be enclosed in curly brackets "{}".
For example, multiple lines of code in your sample code and condition statement branch, etc.
------ Solution --------------------
{} Is actually a block, a whole.
------ Solution --------------------
It is declared that this is a variable, because sometimes "" and ''will encounter errors, which avoids
------ Solution --------------------
This is basically used to enclose variables, which can be safely used as real variables in strings.
------ Solution --------------------
This has nothing to do with SQL. you have explained the role upstairs.
------ Solution --------------------
It seems that there is little relationship.
------ Solution --------------------
The difference is not big. one is to repair the house without a security helmet, and the other is to repair the house with a security helmet !!