: This article describes $ in $ str in php. For more information about PHP tutorials, see. This method is called variable.
Sometimes it is convenient to use a variable name. That is to say, the variable name of a variable can be dynamically set and used. A common variable is set through declaration, for example:
$ A = "hello ";
?>
A variable obtains the value of a common variable as the variable name of the variable. In the preceding example, after using two dollar signs ($), hello can be used as a variable of variable. For example:
$ A = "world ";
?>
At this time, both variables are defined: $ a's content is "hello" and $ hello's content is "world ". Therefore, it can be expressed:
Echo "$ a $ {$ }";
?>
The following statement is more accurate and the same result is output:
Echo "$ a $ hello ";
?>
They all output: hello world.
To use variables in an array, you must solve an ambiguous problem. When writing $ a [1], the parser needs to know that $ a [1] is used as a variable, you still want $ a as a variable and retrieve the value of [1] in the variable. The syntax for solving this problem is to use $ {$ a [1]} for the first case and $ {$ a} [1] for the second case.
The above describes the explanation of "$" in $ str in php, including some content, and hope to help those who are interested in PHP tutorials.