`
chengxianju
  • 浏览: 261348 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

php中的可变变量

    博客分类:
  • php
PHP 
阅读更多

感觉这个东西没什么多大作用,只会降低程序的可读性

<?php
 class Test{
	var $a='4nail';
 }
 $test=new Test();
 $b='a';
 echo $test->$b;//output:4nail
 echo  '<br />';
 $arr=array('sdfsd','test');
 $arr2='arr';
 $r='snail';
 echo ${$arr2}[1];//output:test,最好用{}区分歧义
 echo $$arr2[1];//output:snail
 echo ${$arr2[1]};//output:snail,和上面一样
 echo '<br />';
 $m='hello';
 $hello='world';
 echo  "$m ${$m}";//output:hello world
?>

  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics