Constants

FILTER_VALIDATE_BOOL

FILTER_VALIDATE_BOOL = \FILTER_VALIDATE_BOOLEAN

MB_CASE_LOWER

MB_CASE_LOWER = 1

MB_CASE_TITLE

MB_CASE_TITLE = 2

MB_CASE_UPPER

MB_CASE_UPPER = 0

PHP_FLOAT_DIG

PHP_FLOAT_DIG = 15

PHP_FLOAT_EPSILON

PHP_FLOAT_EPSILON = 2.2204460492503E-16

PHP_FLOAT_MAX

PHP_FLOAT_MAX = 1.7976931348623157E+308

PHP_FLOAT_MIN

PHP_FLOAT_MIN = 2.2250738585072E-308

PHP_OS_FAMILY

PHP_OS_FAMILY = \Symfony\Polyfill\Php72\Php72::php_os_family()

Functions

abort()

abort(int|\Response  $code, string  $message = '', array  $header = []) : mixed

抛出HTTP异常

Parameters

int|\Response $code

状态码 或者 Response对象实例

string $message

错误信息

array $header

参数

Returns

mixed —

app()

app(string  $name = '', array  $args = [], bool  $newInstance = false) : object|\App

快速获取容器中的实例 支持依赖注入

Parameters

string $name

类名或标识 默认获取当前应用实例

array $args

参数

bool $newInstance

是否每次创建新的实例

Returns

object|\App —

app_path()

app_path(string  $path = '') : string

获取当前应用目录

Parameters

string $path

Returns

string —

base_path()

base_path(string  $path = '') : string

获取应用基础目录

Parameters

string $path

Returns

string —

bind()

bind(string|array  $abstract, mixed  $concrete = null) : \Container

绑定一个类到容器

Parameters

string|array $abstract

类标识、接口(支持批量绑定)

mixed $concrete

要绑定的类、闭包或者实例

Returns

\Container —

cache()

cache(string  $name = null, mixed  $value = '', mixed  $options = null, string  $tag = null) : mixed

缓存管理

Parameters

string $name

缓存名称

mixed $value

缓存值

mixed $options

缓存参数

string $tag

缓存标签

Returns

mixed —

class_basename()

class_basename(mixed  $class) : string

获取类名(不包含命名空间)

Parameters

mixed $class

类名

Returns

string —

class_uses_recursive()

class_uses_recursive(mixed  $class) : array

获取一个类里所有用到的trait,包括父类的

Parameters

mixed $class

类名

Returns

array —

collect()

collect(mixed  $value = null) : \Collection

Create a collection from the given value.

Parameters

mixed $value

Returns

\Collection —

composerRequire917cc053b5e8befe21a19371464fc6a9()

composerRequire917cc053b5e8befe21a19371464fc6a9(mixed  $fileIdentifier, mixed  $file) : mixed

Parameters

mixed $fileIdentifier
mixed $file

Returns

mixed —

config()

config(string|array  $name = '', mixed  $value = null) : mixed

获取和设置配置参数

Parameters

string|array $name

参数名

mixed $value

参数值

Returns

mixed —

config_path()

config_path(string  $path = '') : string

获取应用配置目录

Parameters

string $path

Returns

string —

cookie()

cookie(string  $name, mixed  $value = '', mixed  $option = null) : mixed

Cookie管理

Parameters

string $name

cookie名称

mixed $value

cookie值

mixed $option

参数

Returns

mixed —

data_fill()

data_fill(mixed  $target, string|array  $key, mixed  $value) : mixed

Fill in data where it's missing.

Parameters

mixed $target
string|array $key
mixed $value

Returns

mixed —

data_get()

data_get(mixed  $target, string|array|int  $key, mixed  $default = null) : mixed

Get an item from an array or object using "dot" notation.

Parameters

mixed $target
string|array|int $key
mixed $default

Returns

mixed —

data_set()

data_set(mixed  $target, string|array  $key, mixed  $value, bool  $overwrite = true) : mixed

Set an item on an array or object using dot notation.

Parameters

mixed $target
string|array $key
mixed $value
bool $overwrite

Returns

mixed —

dd()

dd(mixed  ...$vars) : mixed

Parameters

mixed $vars variadic

Returns

mixed —

display()

display(string  $content, array  $vars = [], int  $code = 200, callable  $filter = null) : \think\response\View

渲染模板输出

Parameters

string $content

渲染内容

array $vars

模板变量

int $code

状态码

callable $filter

内容过滤

Returns

\think\response\View —

download()

download(string  $filename, string  $name = '', bool  $content = false, int  $expire = 180) : \think\response\File

获取\think\response\Download对象实例

Parameters

string $filename

要下载的文件

string $name

显示文件名

bool $content

是否为内容

int $expire

有效期(秒)

Returns

\think\response\File —

dump()

dump(mixed  $var, mixed  ...$moreVars) : mixed

Parameters

mixed $var
mixed $moreVars variadic

Returns

mixed —

dump()

dump(mixed  ...$vars) : void

浏览器友好的变量输出

Parameters

mixed $vars variadic

要输出的变量

env()

env(string  $name = null, string  $default = null) : mixed

获取环境变量值

Parameters

string $name

环境变量名(支持二级 .号分割)

string $default

默认值

Returns

mixed —

event()

event(mixed  $event, mixed  $args = null) : mixed

触发事件

Parameters

mixed $event

事件名(或者类名)

mixed $args

参数

Returns

mixed —

fdiv()

fdiv(float  $dividend, float  $divisor) : float

Parameters

float $dividend
float $divisor

Returns

float —

get_debug_type()

get_debug_type(mixed  $value) : string

Parameters

mixed $value

Returns

string —

get_resource_id()

get_resource_id(mixed  $res) : int

Parameters

mixed $res

Returns

int —

halt()

halt(mixed  ...$vars) : mixed

调试变量并且中断输出

Parameters

mixed $vars variadic

调试变量或者信息

Returns

mixed —

input()

input(string  $key = '', mixed  $default = null, string  $filter = '') : mixed

获取输入数据 支持默认值和过滤

Parameters

string $key

获取的变量名

mixed $default

默认值

string $filter

过滤方法

Returns

mixed —

invoke()

invoke(mixed  $call, array  $args = []) : mixed

调用反射实例化对象或者执行方法 支持依赖注入

Parameters

mixed $call

类名或者callable

array $args

参数

Returns

mixed —

json()

json(mixed  $data = [], int  $code = 200, array  $header = [], array  $options = []) : \think\response\Json

获取\think\response\Json对象实例

Parameters

mixed $data

返回的数据

int $code

状态码

array $header

头部

array $options

参数

Returns

\think\response\Json —

jsonp()

jsonp(mixed  $data = [], int  $code = 200, array  $header = [], array  $options = []) : \think\response\Jsonp

获取\think\response\Jsonp对象实例

Parameters

mixed $data

返回的数据

int $code

状态码

array $header

头部

array $options

参数

Returns

\think\response\Jsonp —

lang()

lang(string  $name, array  $vars = [], string  $lang = '') : mixed

获取语言变量值

Parameters

string $name

语言变量名

array $vars

动态变量值

string $lang

语言

Returns

mixed —

mb_check_encoding()

mb_check_encoding(mixed  $var = null, mixed  $encoding = null) : mixed

Parameters

mixed $var
mixed $encoding

Returns

mixed —

mb_chr()

mb_chr(mixed  $code, mixed  $enc = null) : mixed

Parameters

mixed $code
mixed $enc

Returns

mixed —

mb_chr()

mb_chr(mixed  $code, mixed  $enc = null) : mixed

Parameters

mixed $code
mixed $enc

Returns

mixed —

mb_convert_case()

mb_convert_case(mixed  $s, mixed  $mode, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $mode
mixed $enc

Returns

mixed —

mb_convert_encoding()

mb_convert_encoding(mixed  $s, mixed  $to, mixed  $from = null) : mixed

Parameters

mixed $s
mixed $to
mixed $from

Returns

mixed —

mb_convert_variables()

mb_convert_variables(mixed  $toEncoding, mixed  $fromEncoding, mixed  $a = null, mixed  $b = null, mixed  $c = null, mixed  $d = null, mixed  $e = null, mixed  $f = null) : mixed

Parameters

mixed $toEncoding
mixed $fromEncoding
mixed $a
mixed $b
mixed $c
mixed $d
mixed $e
mixed $f

Returns

mixed —

mb_decode_mimeheader()

mb_decode_mimeheader(mixed  $s) : mixed

Parameters

mixed $s

Returns

mixed —

mb_decode_numericentity()

mb_decode_numericentity(mixed  $s, mixed  $convmap, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $convmap
mixed $enc

Returns

mixed —

mb_detect_encoding()

mb_detect_encoding(mixed  $str, mixed  $encodingList = null, mixed  $strict = false) : mixed

Parameters

mixed $str
mixed $encodingList
mixed $strict

Returns

mixed —

mb_detect_order()

mb_detect_order(mixed  $encodingList = null) : mixed

Parameters

mixed $encodingList

Returns

mixed —

mb_encode_mimeheader()

mb_encode_mimeheader(mixed  $s, mixed  $charset = null, mixed  $transferEnc = null, mixed  $lf = null, mixed  $indent = null) : mixed

Parameters

mixed $s
mixed $charset
mixed $transferEnc
mixed $lf
mixed $indent

Returns

mixed —

mb_encode_numericentity()

mb_encode_numericentity(mixed  $s, mixed  $convmap, mixed  $enc = null, mixed  $is_hex = false) : mixed

Parameters

mixed $s
mixed $convmap
mixed $enc
mixed $is_hex

Returns

mixed —

mb_encoding_aliases()

mb_encoding_aliases(mixed  $encoding) : mixed

Parameters

mixed $encoding

Returns

mixed —

mb_get_info()

mb_get_info(mixed  $type = 'all') : mixed

Parameters

mixed $type

Returns

mixed —

mb_http_input()

mb_http_input(mixed  $type = '') : mixed

Parameters

mixed $type

Returns

mixed —

mb_http_output()

mb_http_output(mixed  $enc = null) : mixed

Parameters

mixed $enc

Returns

mixed —

mb_internal_encoding()

mb_internal_encoding(mixed  $enc = null) : mixed

Parameters

mixed $enc

Returns

mixed —

mb_language()

mb_language(mixed  $lang = null) : mixed

Parameters

mixed $lang

Returns

mixed —

mb_list_encodings()

mb_list_encodings() : mixed

Returns

mixed —

mb_ord()

mb_ord(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_ord()

mb_ord(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_output_handler()

mb_output_handler(mixed  $contents, mixed  $status) : mixed

Parameters

mixed $contents
mixed $status

Returns

mixed —

mb_parse_str()

mb_parse_str(mixed  $s, mixed  $result = array()) : mixed

Parameters

mixed $s
mixed $result

Returns

mixed —

mb_scrub()

mb_scrub(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_scrub()

mb_scrub(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_str_split()

mb_str_split(mixed  $string, mixed  $split_length = 1, mixed  $encoding = null) : mixed

Parameters

mixed $string
mixed $split_length
mixed $encoding

Returns

mixed —

mb_stripos()

mb_stripos(mixed  $s, mixed  $needle, mixed  $offset, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $offset
mixed $enc

Returns

mixed —

mb_stristr()

mb_stristr(mixed  $s, mixed  $needle, mixed  $part = false, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $part
mixed $enc

Returns

mixed —

mb_strlen()

mb_strlen(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_strpos()

mb_strpos(mixed  $s, mixed  $needle, mixed  $offset, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $offset
mixed $enc

Returns

mixed —

mb_strrchr()

mb_strrchr(mixed  $s, mixed  $needle, mixed  $part = false, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $part
mixed $enc

Returns

mixed —

mb_strrichr()

mb_strrichr(mixed  $s, mixed  $needle, mixed  $part = false, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $part
mixed $enc

Returns

mixed —

mb_strripos()

mb_strripos(mixed  $s, mixed  $needle, mixed  $offset, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $offset
mixed $enc

Returns

mixed —

mb_strrpos()

mb_strrpos(mixed  $s, mixed  $needle, mixed  $offset, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $offset
mixed $enc

Returns

mixed —

mb_strstr()

mb_strstr(mixed  $s, mixed  $needle, mixed  $part = false, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $needle
mixed $part
mixed $enc

Returns

mixed —

mb_strtolower()

mb_strtolower(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_strtoupper()

mb_strtoupper(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_strwidth()

mb_strwidth(mixed  $s, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $enc

Returns

mixed —

mb_substitute_character()

mb_substitute_character(mixed  $char = null) : mixed

Parameters

mixed $char

Returns

mixed —

mb_substr()

mb_substr(mixed  $s, mixed  $start, mixed  $length = 2147483647, mixed  $enc = null) : mixed

Parameters

mixed $s
mixed $start
mixed $length
mixed $enc

Returns

mixed —

mb_substr_count()

mb_substr_count(mixed  $haystack, mixed  $needle, mixed  $enc = null) : mixed

Parameters

mixed $haystack
mixed $needle
mixed $enc

Returns

mixed —

parse_name()

parse_name(string  $name, int  $type, bool  $ucfirst = true) : string

字符串命名风格转换 type 0 将Java风格转换为C的风格 1 将C风格转换为Java的风格

Parameters

string $name

字符串

int $type

转换类型

bool $ucfirst

首字母是否大写(驼峰规则)

Returns

string —

preg_last_error_msg()

preg_last_error_msg() : string

Returns

string —

public_path()

public_path(string  $path = '') : string

获取web根目录

Parameters

string $path

Returns

string —

redirect()

redirect(string  $url = '', int  $code = 302) : \think\response\Redirect

获取\think\response\Redirect对象实例

Parameters

string $url

重定向地址

int $code

状态码

Returns

\think\response\Redirect —

request()

request() : \Request

获取当前Request对象实例

Returns

\Request —

response()

response(mixed  $data = '', int|string  $code = 200, array  $header = [], string  $type = 'html') : \Response

创建普通 Response 对象实例

Parameters

mixed $data

输出数据

int|string $code

状态码

array $header

头信息

string $type

Returns

\Response —

root_path()

root_path(string  $path = '') : string

获取项目根目录

Parameters

string $path

Returns

string —

runtime_path()

runtime_path(string  $path = '') : string

获取应用运行时目录

Parameters

string $path

Returns

string —

sapi_windows_vt100_support()

sapi_windows_vt100_support(mixed  $stream, mixed  $enable = null) : mixed

Parameters

mixed $stream
mixed $enable

Returns

mixed —

session()

session(string  $name = '', mixed  $value = '') : mixed

Session管理

Parameters

string $name

session名称

mixed $value

session值

Returns

mixed —

spl_object_id()

spl_object_id(mixed  $s) : mixed

Parameters

mixed $s

Returns

mixed —

str_contains()

str_contains(string  $haystack, string  $needle) : bool

Parameters

string $haystack
string $needle

Returns

bool —

str_ends_with()

str_ends_with(string  $haystack, string  $needle) : bool

Parameters

string $haystack
string $needle

Returns

bool —

str_starts_with()

str_starts_with(string  $haystack, string  $needle) : bool

Parameters

string $haystack
string $needle

Returns

bool —

stream_isatty()

stream_isatty(mixed  $stream) : mixed

Parameters

mixed $stream

Returns

mixed —

tap()

tap(mixed  $value, callable|null  $callback = null) : mixed

对一个值调用给定的闭包,然后返回该值

Parameters

mixed $value
callable|null $callback

Returns

mixed —

throw_if()

throw_if(mixed  $condition, \Throwable|string  $exception, array  ...$parameters) : mixed

按条件抛异常

Parameters

mixed $condition
\Throwable|string $exception
array $parameters variadic

Throws

\Throwable

Returns

mixed —

throw_unless()

throw_unless(mixed  $condition, \Throwable|string  $exception, array  ...$parameters) : mixed

按条件抛异常

Parameters

mixed $condition
\Throwable|string $exception
array $parameters variadic

Throws

\Throwable

Returns

mixed —

token()

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

获取Token令牌

Parameters

string $name

令牌名称

mixed $type

令牌生成方法

Returns

string —

token_field()

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

生成令牌隐藏表单

Parameters

string $name

令牌名称

mixed $type

令牌生成方法

Returns

string —

token_meta()

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

生成令牌meta

Parameters

string $name

令牌名称

mixed $type

令牌生成方法

Returns

string —

trace()

trace(mixed  $log = '[think]', string  $level = 'log') : array|void

记录日志信息

Parameters

mixed $log

log信息 支持字符串和数组

string $level

日志级别

Returns

array|void —

trait_uses_recursive()

trait_uses_recursive(string  $trait) : array

获取一个trait里所有引用到的trait

Parameters

string $trait

Trait

Returns

array —

url()

url(string  $url = '', array  $vars = [], bool|string  $suffix = true, bool|string  $domain = false) : \UrlBuild

Url生成

Parameters

string $url

路由地址

array $vars

变量

bool|string $suffix

生成的URL后缀

bool|string $domain

域名

Returns

\UrlBuild —

utf8_decode()

utf8_decode(mixed  $s) : mixed

Parameters

mixed $s

Returns

mixed —

utf8_encode()

utf8_encode(mixed  $s) : mixed

Parameters

mixed $s

Returns

mixed —

validate()

validate(string|array  $validate = '', array  $message = [], bool  $batch = false, bool  $failException = true) : \Validate

生成验证对象

Parameters

string|array $validate

验证器类名或者验证规则数组

array $message

错误提示信息

bool $batch

是否批量验证

bool $failException

是否抛出异常

Returns

\Validate —

value()

value(mixed  $value) : mixed

Return the default value of the given value.

Parameters

mixed $value

Returns

mixed —

view()

view(string  $template = '', array  $vars = [], int  $code = 200, callable  $filter = null) : \think\response\View

渲染模板输出

Parameters

string $template

模板文件

array $vars

模板变量

int $code

状态码

callable $filter

内容过滤

Returns

\think\response\View —

xml()

xml(mixed  $data = [], int  $code = 200, array  $header = [], array  $options = []) : \think\response\Xml

获取\think\response\Xml对象实例

Parameters

mixed $data

返回的数据

int $code

状态码

array $header

头部

array $options

参数

Returns

\think\response\Xml —