PHP constants a...LOGIN

PHP constants and variables variable variables

Variable variable, this word is too lofty to explain. Looks very "bigger". It also has a name called a variable.

We think these names are not very scientific. After all, they are all imported things that have been translated.

A variable variable is actually a variable symbol before the declared variable.

Example:

<?php
   //定义了一个变量叫作 $shu 将$shu这个变量的值设为字符串的biao
   $shu = 'biao';
   //定义了一个【变量】$biao。将他的值设置为鼠标
   $biao = '鼠标';

   //$$shu 就是可变变量:在已声明的变量$shu前又加上了一个变量符
   echo $$shu;
?>

Description of the above process: The value of $shu is 'biao' of the string. I add a $ (dollar sign) before $shu, which can be understood as the following transformation process:

$$shu
${$shu} Divide it into two pieces and look at it
${'biao'} interprets the variable $shu as biao
$biao and $biao is also a variable. The corresponding value is: mouse

You can write several variable variables yourself Just for fun, what is the result of running the following code?

<?php
$shu = 'biao';
$biao = 'wo';
$wo = 'test';
$test = 'sina';
$sina = 'zhongguo';
$zhongguo = 'china';
$china = '我爱你';
//别运行,自己去推理一下代码。也写几个可变变量玩玩吧!
echo $$$$$shu;
?>


Next Section
<?php //定义了一个变量叫作 $shu 将$shu这个变量的值设为字符串的biao $shu = 'biao'; //定义了一个【变量】$biao。将他的值设置为鼠标 $biao = '鼠标'; //$$shu 就是可变变量:在已声明的变量$shu前又加上了一个变量符 echo $$shu; ?>
submitReset Code
ChapterCourseware