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 //定義了一個(gè)變量叫作 $shu 將$shu這個(gè)變量的值設(shè)為字符串的biao $shu = 'biao'; //定義了一個(gè)【變量】$biao。將他的值設(shè)置為鼠標(biāo) $biao = '鼠標(biāo)'; //$$shu 就是可變變量:在已聲明的變量$shu前又加上了一個(gè)變量符 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 = '我愛你'; //別運(yùn)行,自己去推理一下代碼。也寫幾個(gè)可變變量玩玩吧! echo $$$$$shu; ?>