For example, $ sqlinsertintoarticle ('Channel _ id', 'title', 'detail', 'pub _ Time') values ({$ cid}, {$ title }, {$ detail}, {$ time}); can be added without adding. What does adding {} mean? Why does the field name need to be included in?
For example, $ SQL = insert into article ('Channel _ id', 'title', 'detail ', 'pub _ Time') values (' {$ cid }', '{$ title}', '{$ detail}', '{$ time}'); can be added without adding? Why does the field name need to be included in? ========================================================== ============
For example:
$ SQL = "insert into article ('Channel _ id', 'title', 'detail ', 'pub _ Time') values (' {$ cid }', '{$ title}', '{$ detail}', '{$ time }');";
It seems that you can do it without adding {}. What does adding {} mean?
Why does the field name need to be included in?
========================================================== ============
Best Answer
At least it is easy to read ~~~ ''Is required by the insert into statement, because the string must appear in pairs, the addition of {} is sometimes used to prevent the variable name and the subsequent string from being connected together. For example, {$ cid} dd If cid = aa then {$ cid} dd = aadd if this parameter is not added, You can see $ ciddd on your own, won't it become a ciddd variable ~~
The meaning of the PHP variable in braces
- // The following is okay as it's inside a string. Constants are not
- // Looked for within strings so no E_NOTICE error here
- Print "Hello $ arr [fruit]"; // Hello apple
-
- // With one exception, braces surrounding arrays within strings
- // Allows constants to be looked
- Print "Hello {$ arr [fruit]}"; // Hello carrot
- Print "Hello {$ arr ['fruit']}"; // Hello apple
The following comparison explains the cause:
- Indicates that the variable in {} is processed according to the variable during execution.
- The special include method used to reference a variable in a string, so that the. operator is not used, thus reducing the input of code.
In fact, the output block is equivalent to print "hello". $ arr ['fruit'];
PHP: The Role of braces (curly braces {}) in string variables
Add a braces {} next to the PHP variable, and fill in a number, which is the character of the corresponding sequence number of the PHP variable.
For example:
$ Str = 'hello ';
Echo $ str {0}; // The output is h.
Echo $ str {1}; // The output is e.
If you want to check whether a string contains a certain length, consider using this braces (curly braces) and isset to replace the strlen function, because isset is a language structure and strlen is a function, therefore, using isset is more efficient than using strlen.
For example, to determine whether the length of a string is less than 5:
If (! Isset ($ str {5}) is better than if (strlen ($ str) <5.