什么是PHP中的"$$"

meo*_*hia 13 php variable-variables

我看到了这段代码

if (is_null($$textVarName)) {
$$textVarName = $_defaultTexts[$type];
}
Run Code Online (Sandbox Code Playgroud)

什么是代码"$$"?

Vot*_*ple 33

这就是它的邪恶.

这将采用其中的值$textVarName并将其用作变量名称.例如:

$foo = 'hello';
$hello = 'The Output';
echo $$foo; // displays "The Output"
Run Code Online (Sandbox Code Playgroud)

  • @Beemer:这是无止境的.顺便说一句,尝试更快 - 而不是要求并等待答案. (5认同)