What does $$ mean in php?

making two spin-to-back $ for the variable. How is it $$ ID

where can i find more information about this Thanks

+2


a source to share


3 answers


In PHP, $$

means that you are going to inflict years of pain and suffering on at least one maintenance programmer. Note that you may end up as a maintenance programmer.

It is a variable variable. Imagine the following:

$quux = 'bar';
$foo[$quux] = "baz";
echo $foo['bar']; //prints baz

      

If it weren't for such a thing as arrays, you can try something like this:



$quux = 'bar';
$$quux = "baz";
echo $bar; //prints baz

      

Luckily we have arrays, so please don't use variable variables unless you are doing something confusing and magical *

and have no other choice.

*

: Please don't do folded magic things.

+10


a source


They are called variable variables .



$foo = 'bar';
$id = 'foo';

echo $id;  // prints foo
echo $$id; // prints bar

      

+6


a source


in the PHP manual of course

http://www.php.net/manual/en/language.variables.variable.php

note that this is an outdated and meaningless syntax and you should always use arrays.

+2


a source







All Articles