core/Request.php
public static function getHeader(string $name = null)
    {
        if (self::$header == null) {
            self::$header = [];
            foreach ($_SERVER as $key => $value) {
                if ('HTTP_' == substr($key, 0, 5)) {
                    $key = strtolower(str_replace('_', '-', substr($key, 5)));
                    self::$header[$key] = $value;
                }
            }
        }
        $list = headers_list();
        foreach ($list as $item) {
            if (preg_match('@^([^:]+):(.*)$@', $item, $mt)) {
                $key = trim($mt[1]);
                $value = trim($mt[2]);
                $key = strtolower(str_replace('_', '-', $key));
                self::$header[$key] = $value;
            }
        }
        if (empty($name)) {
            return self::$header;
        }
        $name = strtolower(str_replace('_', '-', $name));
        return isset(self::$header[$name]) ? self::$header[$name] : '';
    }
public static function getHeader(string $name = null)
    {
        if (self::$header == null) {
            self::$header = [];
            foreach ($_SERVER as $key => $value) {
                if ('HTTP_' == substr($key, 0, 5)) {
                    $key = strtolower(str_replace('_', '-', substr($key, 5)));
                    self::$header[$key] = $value;
                }
            }
        }
        $list = headers_list();
        foreach ($list as $item) {
            if (preg_match('@^([^:]+):(.*)$@', $item, $mt)) {
                $key = trim($mt[1]);
                $value = trim($mt[2]);
                $key = strtolower(str_replace('_', '-', $key));
                self::$header[$key] = $value;
            }
        }
        if (empty($name)) {
            return self::$header;
        }
        $name = strtolower(str_replace('_', '-', $name));
        return isset(self::$header[$name]) ? self::$header[$name] : '';
    }
获取请求头
@param string|null $name
@return array|mixed|null|string