$first ="hello";
$hello ="world";
echo $first." ".$$first;
结果:hello world
$$first就是$hello,因为$first的值是hello
这里的两个$$定义变量代表为可变变量。
另外一种:
$a='hello';
$$a = 'world';
echo "$a ${$a}";
结果:hello world
这种事直接在双引号中输出变量才需要添加{}符号输出,不带的话则是输出变量名$first ="hello";
$hello ="world";
echo $first." ".$$first;
结果:hello world
$$first就是$hello,因为$first的值是hello
这里的两个$$定义变量代表为可变变量。
另外一种:
$a='hello';
$$a = 'world';
echo "$a ${$a}";
结果:hello world
这种事直接在双引号中输出变量才需要添加{}符号输出,不带的话则是输出变量名转载请注明出处: 知识改变命运 » PHP中两个$(美元符号)的用法