PhpSandbox\PHPSandbox::undefineSuperglobal PHP Method

undefineSuperglobal() public method

You can pass a string of superglobal $name to undefine, or a superglobal $key to undefine, or an array of superglobal names to undefine, or an an associative array of superglobal names and keys to undefine
public undefineSuperglobal ( string | array $name, string | null $key = null )
$name string | array String of superglobal $name, or array of superglobal names, or associative array of superglobal names and keys to undefine
$key string | null String of superglobal $key to undefine
    public function undefineSuperglobal($name, $key = null)
    {
        if (is_array($name)) {
            return $this->undefineSuperglobals($name);
        }
        $name = $this->normalizeSuperglobal($name);
        if ($key !== null && is_array($this->definitions['superglobals'][$name])) {
            if (isset($this->definitions['superglobals'][$name][$key])) {
                unset($this->definitions['superglobals'][$name][$key]);
            }
        } else {
            if (isset($this->definitions['superglobals'][$name])) {
                $this->definitions['superglobals'][$name] = [];
            }
        }
        return $this;
    }
PHPSandbox