This article mainly introduces the definition of PHP variables, variable variables, variable references, and destruction methods. For more information, see
The code is as follows:
$ Long = "big_long_variable_name ";
$ Long = "PHP";/* use the string stored in the variable $ long as the name of the new variable, equivalent to $ big_long_variable_name = "PHP ";*/
$ Short = & $ big_long_variable_name;/* assign the value of $ big_long_variable_name to the variable $ short. The value of $ short is "PHP ", equivalent to $ short = & $ long ;*/
Print "01/$ short is $ short.";/* "/$" is an escape sequence, indicating to output a dollar sign $, the same below. The purpose of this statement is to output: 01 $ short is PHP .*/
Print "02 Long is $ big_long_variable_name.";/* output: 02 Long is PHP .*/
?>
Print "03/$ short is $ short";/* output: 03 $ short is PHP rocks! */
Print "04 Long is $ big_long_variable_name";/* output: 04 Long is PHP rocks! */
?>
05 $ short is PHP rocks!
06 Long is PHP rocks!
Print "07/$ short is $ short";/* output: 07 $ short is PHP rocks! Programming PHP rocks! */
Print "08 Long is $ big_long_variable_name";/* the variable $ short is assigned a new value to Programming PHP rocks !, Therefore, the value of $ big_long_variable_name is changed to "PHP rocks!" together with $ short! Programming PHP rocks! ". Output of this statement: 08 Long is PHP rocks! Programming PHP rocks! Note: If you destroy unset () for a variable with the same value, the other variable is not applicable to this situation and will not be destroyed together. */
?>
09 $ short is Programming PHP rocks!
10 Long is Programming PHP rocks!
Print "11/$ short is $ short";/* output: 11 PHP rocks! Programming PHP rocks! Web Programming PHP rocks! Programming PHP rocks! */
Print "12 Long is $ big_long_variable_name ";
?>
Unset ($ big_long_variable_name);/* use unset () to destroy the variable $ big_long_variable_name. the variable $ short will not be affected. */
Print "13/$ short is $ short";/* Although the variable $ big_long_variable_name is destroyed, $ short is not affected and its value is still the PHP rocks that was last granted! Programming PHP rocks! Web Programming PHP rocks! Programming PHP rocks! */
Print "14 Long is $ big_long_variable_name.";/* the variable $ big_long_variable_name has been destroyed and therefore has no value. Output: 14 Long is .*/
Snow;
?>
Print "15/$ short is $ short.";/* output: 15 $ short is No point TEST1 .*/
$ Short = "No point TEST2 $ short";/* value the variable $ short again. No. is added after $ short, but its last value "No point TEST1" is referenced ". */
Print "16/$ short is $ short.";/* output: 16 $ short is No point TEST2 No point TEST1 .*/