Variable variable Superglobals

后端 未结 1 1308
说谎
说谎 2021-01-02 07:58

In PHP ...

var_dump(${\'_GET\'});   // array(0) { } - #1

$var = \'_GET\';
var_dump(${$var});     // array(0) { } - #2

function test() {
  var_dump(${\'_GET         


        
相关标签:
1条回答
  • 2021-01-02 08:15

    It's not a bug, it's a feature:

    Warning

    Please note that variable variables cannot be used with PHP's Superglobal arrays within functions or class methods. The variable $this is also a special variable that cannot be referenced dynamically.

    0 讨论(0)
提交回复
热议问题