PHP可变变量
<?php
header("content-type:text/html;charset=utf-8");
$uername = ‘村里有个姑娘‘;
$name = ‘xiaofang‘;
$xiaofang = ‘大阪城的姑娘‘;
//$$name =$xiaofang
echo $$name;
//可变变量的用法
$banzhuren = ‘xucaihui‘;
$xucaihui = ‘man‘;
$man = ‘lvyou‘;
$lvyou = ‘taiguo‘;
$taiguo = ‘是女的‘;
echo $$$$$banzhuren;
输出结果:大阪城的姑娘是女的
<?php
$user = ‘canglaoshi‘;
$name = ‘wulaoshi‘;
//使$name的值指向$user,并且丢弃$name的值
$name =&$user;
echo $name;
echo ‘<br />‘;
echo $user;
//判断结果是否相同,结果都是10个字节的字符串
if(empty($name)){
echo ‘kong‘;
}else{
echo ‘feikong‘;
};
echo ‘<br/>‘;
var_dump($user);
echo ‘<br/>‘;
var_dump($name);
echo ‘<br/>‘;
//销毁变量$user, $name的输出结果仍然是canglaoshi,足以证明内存中只剩下一个值
unset($user);
echo ‘<br/>‘;
echo $name;
echo $user;
输出结果:
canglaoshi
canglaoshifeikong
string(10) "canglaoshi"
string(10) "canglaoshi"
canglaoshi
Notice: Undefined variable: user in D:\xampp\htdocs\89\Exercise\2014-7-25 PHP kongzhiyuju\01yinyon.php on line 29
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。