PHP learning notes-related variables in php. Variable variables in PHP (For more information, see The php Manual): Variable variables in php are interpreted as a variable name, read the value of the variable name. Example: Variable variables in PHP (For more information, see The php Manual ):
To put it bluntly, the variable in php parses the value of a variable into a variable name and reads the value of that variable name. Instance:
"; $."
"; = "f"; $."
"; = "b"; $."
"; ."
"; $."
"; $$."
"; ."
"; $."
"; $$."
"; $$$."
"; = "China"; ."
"; $; ?>
Note: Variable variables cannot be applied to $ this and Super global variables (the scope of php variables is different from that of other advanced programming languages. View code)
"; ; "
" ; ."
"; "; ['name']; ?>
Variable functions:
A typical application of variable variables:
Untitled Document
$ = ."
"."
"."
"?>
Supplement:
Variable features. If a variable is not declared in advance, if you want to assign a value to a variable, a PHP operation in the background is that when you assign a value to this undeclared variable, the background has already affirmed this variable for you. Let's look at the example:
Name )? "True": "false"). "--"-> = A ();-> show ();-> name = "I have output. This variable is declared! ""
"-> Show ();?>
Summary: After reading the above example, you will see the code encapsulated by others. if there is a variable that is not declared, it will be used directly. Don't be surprised. You must set it yourself. You just need to assign values... (PS: In fact, I am also confused at the beginning, because I used to engage in. NET in C #, it is absolutely not allowed to happen. Strong languages are used... Looking at this weak type of language, it is not very suitable at the beginning)
Callback (For more information, refer to the php Manual): the variable name in php is interpreted as a variable name to read the value of the variable name. Instance :...