Response 响应类

属性
命名空间 fize\web
类名 Response
方法:
方法名 说明
content() 设置或获取响应主体内容
code() HTTP 状态
header() 添加响应头获取返回响应头
contentType() 页面输出类型
send() 发送响应
noCache() 强制浏览器不进行缓存
json() JSON 响应
html() HTML 响应
xml() XML 响应
redirect() 跳转
download() 下载

方法

content()

设置或获取响应主体内容

public function content (
    string $content = null
) : string
参数:
名称 说明
content 主体内容

code()

HTTP 状态

public function code (
    int $code = null
) : int
参数:
名称 说明
code 状态码

contentType()

页面输出类型

public function contentType (
    string $content_type,
    string $charset = "utf-8"
)
参数:
名称 说明
content_type 输出类型
charset 输出编码

send()

发送响应

public function send ()

noCache()

强制浏览器不进行缓存

public static function noCache ()

json()

JSON 响应

public static function json (
    array|string $json,
    string $charset = "utf-8"
) : \fize\web\Response
参数:
名称 说明
json 数组或者 JSON 字符串
charset 输出编码

html()

HTML 响应

public static function html (
    string $html,
    string $charset = "utf-8"
) : \fize\web\Response
参数:
名称 说明
html HTML 内容
charset 输出编码

xml()

XML 响应

public static function xml (
    string $xml,
    string $charset = "utf-8"
) : \fize\web\Response
参数:
名称 说明
xml XML 内容
charset 输出编码

redirect()

跳转

public static function redirect (
    string $url,
    int $delay = null
) : \fize\web\Response
参数:
名称 说明
url 跳转 URL
delay 延迟时间,以秒为单位

download()

下载

public static function download (
    string $file,
    string $filename = null
) : \fize\web\Response
参数:
名称 说明
file 要下载的文件路径
filename 下载文件名