Search code examples
phpvariable-variables

what is "$$" in PHP


I saw this code

if (is_null($$textVarName)) {
$$textVarName = $_defaultTexts[$type];
}

what is code "$$" ?


Solution

  • It's evil is what it is.

    That will take the value that's in $textVarName and use that as a variable name. For example:

    $foo = 'hello';
    $hello = 'The Output';
    echo $$foo; // displays "The Output"