For details about $ str in php, refer to str in php. $ In $ str in php. in php, str is called Variable variables. sometimes it is very convenient to use variable names. That is to say, the variable name of a variable can be dynamically set to "$" in $ str in php, and str in php
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:
<?php$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:
<?php$$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:
<?phpecho "$a ${$a}";?>
The following statement is more accurate and the same result is output:
<?phpecho "$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 is all the content of this article. I hope you will like it.
Description of "$" in explain $ str. in php, str is called Variable variables. sometimes it is very convenient to use variable names. That is to say, the variable name of a variable can be dynamically set...