What is the difference between $a and $$a in php?

Possible Duplicate:
What does $$ mean in PHP?

I am new to PHP and I don't know what the difference between $a and $$a is.


If $a = 'b' then $$a is $b .

This is a variable variable. They are evil. Use arrays instead (which do the same thing, but more maintainably and with the ability to use array functions on them).


$a represents a variable

$$a represents a variable with the content of $a

example:

$test = "hello world";
$a = "test";
echo $$a;

output will be hello world


$a is the contents of the variable a , $$a is the contents of the variable named in $a .

Don't use this syntax in your own code.

链接地址: http://www.djcxy.com/p/59088.html

上一篇: 我从我的朋友那里得到了有关可变美元符号的这个PHP问题

下一篇: $ a和$$ a在php中有什么区别?