天天看点

PHP 可变变量

有时候使用可变变量名是很方便的。

就是说,一个可变变量获取了一个普通变量的值作为这个可变变量的变量名。

举个栗子:

<?php

        $a = 'hello';  //普通变量

  $$a = ‘world’;  //可变变量

  echo "$a ${$a}";  //输出:hello world

  echo "$a $hello";  //输出:hello world

?>