The role of PHP curly braces
When the PHP parser encounters a dollar ($) symbol, he will, like many other parsers, assemble as many tokens as possible to form a valid variable name.
You can use curly braces to define the bounds of a variable, to enclose the variable as a whole to parse
You can make additions and deletions to the specified characters in the string by {curly braces}
Starting from 0 under string
You can use [brackets] to achieve the same operation
Operation relative to an array
$str = ' ABCD '; echo $str {0}; Output $str subscript 0 A$str{1} = ' Z '; Replace B with subscript 1 as Z, (note: You can only replace one character at a time)
Replacing characters with empty is equivalent to deleting an operation
$str = ' Asdasldjasljfas '; Echo $str {Mt_rand (0,strlen ($STR)-1)}; Randomly take one character mt_rand (0,10)//In the middle of 0-10 randomly take a strlen ($STR)//Calculate the length of this variable
Will often appear in the interview questions.
Related recommendations:
PHP curly braces general rules and explanations
PHP Basic Knowledge Summary (Beginner's Essentials)
PHP basic operator and control structure flow code example