可变变量的概念:通过获取一个变量的值做为另外一个变量的名称来操作变量,就是可以变量。
- $method = "save".ucfirst($data_type['input_table'])."_".$file_info['file_type'] ;
- $this->$method( &$file_info );
- for($i=1;$i<5;$i++){
- $name = "name_".$i;
- $$name='test'.$i;
- }
- $result=$this->_statement->{$method}($mode);
- eval('$this->'.$_GET['flashreport'].'();');
- <?php
- $a = 'hello' ; //普通变量
- $$a = 'world' ; //可变变量 ,相当于 $hello='world';
- echo "$a $hello" ; //输出:hello world
- echo $$a ; //输出:world
- echo "$a ${$a}" ; //输出:hello world
- echo "$a {$$a}" ; //输出:hello world
- $string = "beautiful";
- $time = "winter";
- $str = 'This is a $string $time morning!';
- echo $str. "<br />";
- eval("\$str = \"$str\";");
- echo $str;
- This is a $string $time morning!
- This is a beautiful winter morning!
- eval('$a=55;');