Properties

$data

$data : mixed

原始数据

Type

mixed

$contentType

$contentType : string

当前contentType

Type

string

$charset

$charset : string

字符集

Type

string

$code

$code : int

状态码

Type

int

$allowCache

$allowCache : bool

是否允许请求缓存

Type

bool

$options

$options : array

输出参数

Type

array

$header

$header : array

header参数

Type

array

$content

$content : string

输出内容

Type

string

$cookie

$cookie : \think\Cookie

Cookie对象

Type

Cookie

$session

$session : \think\Session

Session对象

Type

Session

$expire

$expire

$name

$name

$mimeType

$mimeType

$isContent

$isContent

$force

$force

Methods

create()

create(mixed  $data = '', string  $type = 'html', int  $code = 200) : \think\Response

创建Response对象

Parameters

mixed $data

输出数据

string $type

输出类型

int $code

状态码

Returns

\think\Response —

setSession()

setSession(\think\Session  $session) : $this

设置Session对象

Parameters

\think\Session $session

Session对象

Returns

$this —

send()

send() : void

发送数据到客户端

Throws

\InvalidArgumentException

options()

options(mixed  $options = []) : $this

输出的参数

Parameters

mixed $options

输出参数

Returns

$this —

data()

data(mixed  $data) : $this

输出数据设置

Parameters

mixed $data

输出数据

Returns

$this —

allowCache()

allowCache(bool  $cache) : $this

是否允许请求缓存

Parameters

bool $cache

允许请求缓存

Returns

$this —

isAllowCache()

isAllowCache() : $this

是否允许请求缓存

Returns

$this —

cookie()

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

设置Cookie

Parameters

string $name

cookie名称

string $value

cookie值

mixed $option

可选参数

Returns

$this —

header()

header(array  $header = []) : $this

设置响应头

Parameters

array $header

参数

Returns

$this —

content()

content(mixed  $content) : $this

设置页面输出内容

Parameters

mixed $content

Returns

$this —

code()

code(int  $code) : $this

发送HTTP状态

Parameters

int $code

状态码

Returns

$this —

lastModified()

lastModified(string  $time) : $this

LastModified

Parameters

string $time

Returns

$this —

expires()

expires(string  $time) : $this

Expires

Parameters

string $time

Returns

$this —

eTag()

eTag(string  $eTag) : $this

ETag

Parameters

string $eTag

Returns

$this —

cacheControl()

cacheControl(string  $cache) : $this

页面缓存控制

Parameters

string $cache

状态码

Returns

$this —

contentType()

contentType(string  $contentType, string  $charset = 'utf-8') : $this

页面输出类型

Parameters

string $contentType

输出类型

string $charset

输出编码

Returns

$this —

getHeader()

getHeader(string  $name = '') : mixed

获取头部信息

Parameters

string $name

头部名称

Returns

mixed —

getData()

getData() : mixed

获取原始数据

Returns

mixed —

getContent()

getContent() : string

获取输出数据

Returns

string —

getCode()

getCode() : int

获取状态码

Returns

int —

__construct()

__construct(mixed  $data = '', int  $code = 200) : mixed

Parameters

mixed $data
int $code

Returns

mixed —

isContent()

isContent(bool  $content = true) : $this

设置是否为内容 必须配合mimeType方法使用

Parameters

bool $content

Returns

$this —

expire()

expire(int  $expire) : $this

设置有效期

Parameters

int $expire

有效期

Returns

$this —

mimeType()

mimeType(string  $mimeType) : $this

设置文件类型

Parameters

string $mimeType

Returns

$this —

force()

force(bool  $force) : $this

设置文件强制下载

Parameters

bool $force

强制浏览器下载

Returns

$this —

name()

name(string  $filename, bool  $extension = true) : $this

设置下载文件的显示名称

Parameters

string $filename

文件名

bool $extension

后缀自动识别

Returns

$this —

init()

init(mixed  $data = '', int  $code = 200) : mixed

初始化

Parameters

mixed $data

输出数据

int $code

状态码

Returns

mixed —

output()

output(mixed  $data) : mixed

处理数据

Parameters

mixed $data

要处理的数据

Throws

\Exception

Returns

mixed —

sendData()

sendData(string  $data) : void

输出数据

Parameters

string $data

要处理的数据

getMimeType()

getMimeType(string  $filename) : string

获取文件类型信息

Parameters

string $filename

文件名

Returns

string —