Xeo*_*oss 4 php static-methods
以下代码在我的安装上失败,PHP 5.3.6-13ubuntu3.2这让我想知道为什么我无法在此方法中访问$ _SERVER Super Global.
<?php
header('Content-Type: text/plain');
$method = '_SERVER';
var_dump($$method); // Works fine
class i
{
public static function __callStatic($method, $args)
{
$method = '_SERVER';
var_dump($$method); // Notice: Undefined variable: _SERVER
}
}
i::method();
Run Code Online (Sandbox Code Playgroud)
谁知道这里有什么问题?
如手册中所示:
Note: Variable variables
Superglobals cannot be used as variable variables inside functions or class methods.
Run Code Online (Sandbox Code Playgroud)
(参考)