What is $$ in php?
Possible Duplicate:
What does $$ mean in PHP?
Double dollar sign php
What is $$ in php. This question is asked in a recent interview for a web developer position. Thanks in advance!
This is a variable variable. They work by using a variable to contain the name of another variable like so:
$var = 'test';
$test = 'echod variable';
echo $$var;
// output echod variable
It's a variable variable:
Sometimes it is convenient to be able to have variable variable names. That is, a variable name which can be set and used dynamically.
dynamic variable name,
for example
for($i = 0; $i<10; $i++)
{
$var_name = "d".$i;
echo $$var_name;
}
will echo the variables $d0, $d1, $d2, $d3... $d9
链接地址: http://www.djcxy.com/p/59096.html上一篇: php $$操作符
下一篇: PHP中的$$是什么?