Properties

$instance

$instance : object

对象实例

Type

object

$config

$config : \think\Config

配置对象

Type

\think\Config

$method

$method : string

请求类型

Type

string

$domain

$domain : string

域名(含协议及端口)

Type

string

$subDomain

$subDomain : string

子域名

Type

string

$panDomain

$panDomain : string

泛域名

Type

string

$url

$url : string

当前URL地址

Type

string

$baseUrl

$baseUrl : string

基础URL

Type

string

$baseFile

$baseFile : string

当前执行的文件

Type

string

$root

$root : string

访问的ROOT地址

Type

string

$pathinfo

$pathinfo : string

pathinfo

Type

string

$path

$path : string

pathinfo(不含后缀)

Type

string

$routeInfo

$routeInfo : array

当前路由信息

Type

array

$dispatch

$dispatch : array

当前调度信息

Type

array

$module

$module : string

当前模块名

Type

string

$controller

$controller : string

当前控制器名

Type

string

$action

$action : string

当前操作名

Type

string

$langset

$langset : string

当前语言集

Type

string

$param

$param : array

当前请求参数

Type

array

$get

$get : array

当前GET参数

Type

array

$post

$post : array

当前POST参数

Type

array

$request

$request : array

当前REQUEST参数

Type

array

$route

$route : array

当前ROUTE参数

Type

array

$put

$put : array

当前PUT参数

Type

array

$session

$session : array

当前SESSION参数

Type

array

$file

$file : array

当前FILE参数

Type

array

$cookie

$cookie : array

当前COOKIE参数

Type

array

$server

$server : array

当前SERVER参数

Type

array

$env

$env : array

当前ENV参数

Type

array

$header

$header : array

当前HEADER参数

Type

array

$mimeType

$mimeType : array

资源类型定义

Type

array

$content

$content : string

当前请求内容

Type

string

$filter

$filter : array

全局过滤规则

Type

array

$hook

$hook : array

扩展方法

Type

array

$input

$input : 

Type

$cache

$cache : array

请求缓存

Type

array

$isCheckCache

$isCheckCache : boolean

缓存是否检查

Type

boolean

$secureKey

$secureKey : string

请求安全Key

Type

string

Methods

__construct()

__construct(array  $options = array()) 

架构函数

Parameters

array $options

参数

__call()

__call(  $method,   $args) 

Parameters

$method
$args

hook()

hook(string|array  $method, mixed  $callback = null) : void

Hook 方法注入

Parameters

string|array $method

方法名

mixed $callback

callable

create()

create(string  $uri, string  $method = 'GET', array  $params = array(), array  $cookie = array(), array  $files = array(), array  $server = array(), string  $content = null) : \think\Request

创建一个URL请求

Parameters

string $uri

URL地址

string $method

请求类型

array $params

请求参数

array $cookie
array $files
array $server
string $content

Returns

\think\Request

domain()

domain(string  $domain = null) : string|$this

设置或获取当前包含协议的域名

Parameters

string $domain

域名

Returns

string|$this

rootDomain()

rootDomain() : string

获取当前根域名

Returns

string

subDomain()

subDomain() : string

获取当前子域名

Returns

string

panDomain()

panDomain(string  $domain = null) : string|$this

设置或获取当前泛域名的值

Parameters

string $domain

域名

Returns

string|$this

url()

url(string|true  $url = null) : string|$this

设置或获取当前完整URL 包括QUERY_STRING

Parameters

string|true $url

URL地址 true 带域名获取

Returns

string|$this

baseUrl()

baseUrl(string  $url = null) : string|$this

设置或获取当前URL 不含QUERY_STRING

Parameters

string $url

URL地址

Returns

string|$this

baseFile()

baseFile(string  $file = null) : string|$this

设置或获取当前执行的文件 SCRIPT_NAME

Parameters

string $file

当前执行的文件

Returns

string|$this

root()

root(string  $url = null) : string|$this

设置或获取URL访问根地址

Parameters

string $url

URL地址

Returns

string|$this

rootUrl()

rootUrl() : string

获取URL访问根目录

Returns

string

pathinfo()

pathinfo() : string

获取当前请求URL的pathinfo信息(含URL后缀)

Returns

string

path()

path() : string

获取当前请求URL的pathinfo信息(不含URL后缀)

Returns

string

ext()

ext() : string

当前URL的访问后缀

Returns

string

time()

time(boolean  $float = false) : integer|float

获取当前请求的时间

Parameters

boolean $float

是否使用浮点类型

Returns

integer|float

type()

type() : false|string

当前请求的资源类型

Returns

false|string

mimeType()

mimeType(string|array  $type, string  $val = '') : void

设置资源类型

Parameters

string|array $type

资源类型名

string $val

资源类型

method()

method(boolean  $method = false) : string

当前的请求类型

Parameters

boolean $method

true 获取原始请求类型

Returns

string

isGet()

isGet() : boolean

是否为GET请求

Returns

boolean

isPost()

isPost() : boolean

是否为POST请求

Returns

boolean

isPut()

isPut() : boolean

是否为PUT请求

Returns

boolean

isDelete()

isDelete() : boolean

是否为DELTE请求

Returns

boolean

isHead()

isHead() : boolean

是否为HEAD请求

Returns

boolean

isPatch()

isPatch() : boolean

是否为PATCH请求

Returns

boolean

isOptions()

isOptions() : boolean

是否为OPTIONS请求

Returns

boolean

isCli()

isCli() : boolean

是否为cli

Returns

boolean

isCgi()

isCgi() : boolean

是否为cgi

Returns

boolean

param()

param(mixed  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

获取当前请求的参数

Parameters

mixed $name

变量名

mixed $default

默认值

string|array $filter

过滤方法

Returns

mixed

route()

route(mixed  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

设置获取路由参数

Parameters

mixed $name

变量名

mixed $default

默认值

string|array $filter

过滤方法

Returns

mixed

get()

get(mixed  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

设置获取GET参数

Parameters

mixed $name

变量名

mixed $default

默认值

string|array $filter

过滤方法

Returns

mixed

post()

post(mixed  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

设置获取POST参数

Parameters

mixed $name

变量名

mixed $default

默认值

string|array $filter

过滤方法

Returns

mixed

put()

put(mixed  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

设置获取PUT参数

Parameters

mixed $name

变量名

mixed $default

默认值

string|array $filter

过滤方法

Returns

mixed

delete()

delete(mixed  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

设置获取DELETE参数

Parameters

mixed $name

变量名

mixed $default

默认值

string|array $filter

过滤方法

Returns

mixed

patch()

patch(mixed  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

设置获取PATCH参数

Parameters

mixed $name

变量名

mixed $default

默认值

string|array $filter

过滤方法

Returns

mixed

request()

request(mixed  $name = '', string  $default = null, string|array  $filter = '') : mixed

获取request变量

Parameters

mixed $name

数据名称

string $default

默认值

string|array $filter

过滤方法

Returns

mixed

session()

session(mixed  $name = '', string  $default = null, string|array  $filter = '') : mixed

获取session数据

Parameters

mixed $name

数据名称

string $default

默认值

string|array $filter

过滤方法

Returns

mixed

cookie()

cookie(mixed  $name = '', string  $default = null, string|array  $filter = '') : mixed

获取cookie参数

Parameters

mixed $name

数据名称

string $default

默认值

string|array $filter

过滤方法

Returns

mixed

server()

server(mixed  $name = '', string  $default = null, string|array  $filter = '') : mixed

获取server参数

Parameters

mixed $name

数据名称

string $default

默认值

string|array $filter

过滤方法

Returns

mixed

file()

file(string|array  $name = '') : null|array|\think\File

获取上传的文件信息

Parameters

string|array $name

名称

Returns

null|array|\think\File

env()

env(mixed  $name = '', string  $default = null, string|array  $filter = '') : mixed

获取环境变量

Parameters

mixed $name

数据名称

string $default

默认值

string|array $filter

过滤方法

Returns

mixed

header()

header(string|array  $name = '', string  $default = null) : string

设置或者获取当前的Header

Parameters

string|array $name

header名称

string $default

默认值

Returns

string

input()

input(array  $data = array(), string|false  $name = '', mixed  $default = null, string|array  $filter = '') : mixed

获取变量 支持过滤和默认值

Parameters

array $data

数据源

string|false $name

字段名

mixed $default

默认值

string|array $filter

过滤函数

Returns

mixed

filter()

filter(mixed  $filter = null) : mixed

设置或获取当前的过滤规则

Parameters

mixed $filter

过滤规则

Returns

mixed

has()

has(string  $name, string  $type = 'param', boolean  $checkEmpty = false) : mixed

是否存在某个请求参数

Parameters

string $name

变量名

string $type

变量类型

boolean $checkEmpty

是否检测空值

Returns

mixed

only()

only(string|array  $name, string  $type = 'param') : mixed

获取指定的参数

Parameters

string|array $name

变量名

string $type

变量类型

Returns

mixed

except()

except(string|array  $name, string  $type = 'param') : mixed

排除指定参数获取

Parameters

string|array $name

变量名

string $type

变量类型

Returns

mixed

isSsl()

isSsl() : boolean

当前是否ssl

Returns

boolean

isAjax()

isAjax(boolean  $ajax = false) : boolean

当前是否Ajax请求

Parameters

boolean $ajax

true 获取原始ajax请求

Returns

boolean

isPjax()

isPjax(boolean  $pjax = false) : boolean

当前是否Pjax请求

Parameters

boolean $pjax

true 获取原始pjax请求

Returns

boolean

ip()

ip(integer  $type, boolean  $adv = true) : mixed

获取客户端IP地址

Parameters

integer $type

返回类型 0 返回IP地址 1 返回IPV4地址数字

boolean $adv

是否进行高级模式获取(有可能被伪装)

Returns

mixed

isMobile()

isMobile() : boolean

检测是否使用手机访问

Returns

boolean

scheme()

scheme() : string

当前URL地址中的scheme参数

Returns

string

query()

query() : string

当前请求URL地址中的query参数

Returns

string

host()

host() : string

当前请求的host

Returns

string

port()

port() : integer

当前请求URL地址中的port参数

Returns

integer

protocol()

protocol() : integer

当前请求 SERVER_PROTOCOL

Returns

integer

remotePort()

remotePort() : integer

当前请求 REMOTE_PORT

Returns

integer

contentType()

contentType() : string

当前请求 HTTP_CONTENT_TYPE

Returns

string

routeInfo()

routeInfo(array  $route = array()) : array

获取当前请求的路由信息

Parameters

array $route

路由名称

Returns

array

dispatch()

dispatch(array  $dispatch = null) : array

设置或者获取当前请求的调度信息

Parameters

array $dispatch

调度信息

Returns

array

secureKey()

secureKey() : string

获取当前请求的安全Key

Returns

string

module()

module(string  $module = null) : string|\think\Request

设置或者获取当前的模块名

Parameters

string $module

模块名

Returns

string|\think\Request

controller()

controller(string  $controller = null) : string|\think\Request

设置或者获取当前的控制器名

Parameters

string $controller

控制器名

Returns

string|\think\Request

action()

action(string  $action = null) : string|\think\Request

设置或者获取当前的操作名

Parameters

string $action

操作名

Returns

string|\think\Request

langset()

langset(string  $lang = null) : string|\think\Request

设置或者获取当前的语言

Parameters

string $lang

语言名

Returns

string|\think\Request

getContent()

getContent() : string

设置或者获取当前请求的content

Returns

string

getInput()

getInput() : string

获取当前请求的php://input

Returns

string

token()

token(string  $name = '__token__', mixed  $type = 'md5') : string

生成请求令牌

Parameters

string $name

令牌名称

mixed $type

令牌生成方法

Returns

string

cache()

cache(string  $key, mixed  $expire = null, array  $except = array(), string  $tag = null) : void

设置当前地址的请求缓存

Parameters

string $key

缓存标识,支持变量规则 ,例如 item/:name/:id

mixed $expire

缓存有效期

array $except

缓存排除

string $tag

缓存标签

getCache()

getCache() : array

读取请求缓存设置

Returns

array

__get()

__get(string  $name) : mixed

获取请求数据的值

Parameters

string $name

名称

Returns

mixed

dealUploadFile()

dealUploadFile(  $files) 

Parameters

$files

getFilter()

getFilter(  $filter,   $default) 

Parameters

$filter
$default

filterValue()

filterValue(mixed  $value, mixed  $key, array  $filters) : mixed

递归过滤给定的值

Parameters

mixed $value

键值

mixed $key

键名

array $filters

过滤方法+默认值

Returns

mixed

typeCast()

typeCast(string  $data, string  $type) : mixed

强制类型转换

Parameters

string $data
string $type

Returns

mixed