Request 请求类

属性
命名空间 fize\web
类名 Request
方法:
方法名 说明
__construct() 初始化静态属性
server() 获取原生 SERVER
get() 获取 GET 参数
post() 获取 POST 参数
files() 获取上传文件
request() 获取 REQUEST 参数
session() 获取 SESSION 参数
env() 获取 ENV 参数
cookie() 获取 COOKIE 参数
input() 返回原始输入数据
header() 获取请求头
contentType() 当前请求 HTTP_CONTENT_TYPE
method() 当前的请求类型
isGet() 是否为 GET 请求
isPost() 是否为 POST 请求
isPut() 是否为 PUT 请求
isDelete() 是否为 DELTE 请求
isHead() 是否为 HEAD 请求
isPatch() 是否为 PATCH 请求
isOptions() 是否为 OPTIONS 请求
isCli() 是否为 cli
isCgi() 是否为 cgi
isSsl() 当前是否 ssl
isJson() 当前是否 JSON 请求
isAjax() 当前是否 Ajax 请求
isPjax() 当前是否 Pjax 请求
isMobile() 检测是否使用手机访问
url() 返回当前请求 URL

方法

__construct()

初始化静态属性

public function __construct (
    array $config = []
)
参数:
名称 说明
config 配置

server()

获取原生 SERVER

public static function server (
    string $key = null,
    string $default = null
) : mixed
参数:
名称 说明
key 键名
default 默认值

get()

获取 GET 参数

public static function get (
    string $key = null,
    string $default = null
) : mixed
参数:
名称 说明
key 键名
default 默认值

post()

获取 POST 参数

public static function post (
    string $key = null,
    string $default = null
) : mixed
参数:
名称 说明
key 键名
default 默认值

files()

获取上传文件

public static function files (
    string $key = null
) : mixed
参数:
名称 说明
key 键名

request()

获取 REQUEST 参数

public static function request (
    string $key = null
) : mixed
参数:
名称 说明
key 键名

session()

获取 SESSION 参数

public static function session (
    string $key = null,
    string $default = null
) : mixed
参数:
名称 说明
key 键名
default 默认值

env()

获取 ENV 参数

public static function env (
    string $key = null,
    string $default = null
) : mixed
参数:
名称 说明
key 键名
default 默认值

input()

返回原始输入数据

public static function input () : string
返回值:失败时返回 false

contentType()

当前请求 HTTP_CONTENT_TYPE

public static function contentType () : string

method()

当前的请求类型

public static function method () : string

isGet()

是否为 GET 请求

public static function isGet () : bool

isPost()

是否为 POST 请求

public static function isPost () : bool

isPut()

是否为 PUT 请求

public static function isPut () : bool

isDelete()

是否为 DELTE 请求

public static function isDelete () : bool

isHead()

是否为 HEAD 请求

public static function isHead () : bool

isPatch()

是否为 PATCH 请求

public static function isPatch () : bool

isOptions()

是否为 OPTIONS 请求

public static function isOptions () : bool

isCli()

是否为 cli

public static function isCli () : bool

isCgi()

是否为 cgi

public static function isCgi () : bool

isSsl()

当前是否 ssl

public static function isSsl () : bool

isJson()

当前是否 JSON 请求

public static function isJson () : bool

isAjax()

当前是否 Ajax 请求

public static function isAjax () : bool

isPjax()

当前是否 Pjax 请求

public static function isPjax () : bool

isMobile()

检测是否使用手机访问

public static function isMobile () : bool

url()

返回当前请求 URL

public static function url (
    bool $host = true,
    bool $protocol = true
) : string
参数:
名称 说明
host 是否携带主机名
protocol 是否携带协议