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
| 参数: |
|
|---|
header()¶
添加响应头获取返回响应头
public function header (
mixed $header = null,
null $value = null
) : array
| 参数: |
|
||||||
|---|---|---|---|---|---|---|---|
| 返回值: | 返回响应头 |
contentType()¶
页面输出类型
public function contentType (
string $content_type,
string $charset = "utf-8"
)
| 参数: |
|
|---|
json()¶
JSON 响应
public static function json (
array|string $json,
string $charset = "utf-8"
) : \fize\web\Response
| 参数: |
|
|---|
html()¶
HTML 响应
public static function html (
string $html,
string $charset = "utf-8"
) : \fize\web\Response
| 参数: |
|
|---|
xml()¶
XML 响应
public static function xml (
string $xml,
string $charset = "utf-8"
) : \fize\web\Response
| 参数: |
|
|---|
redirect()¶
跳转
public static function redirect (
string $url,
int $delay = null
) : \fize\web\Response
| 参数: |
|
|---|
download()¶
下载
public static function download (
string $file,
string $filename = null
) : \fize\web\Response
| 参数: |
|
|---|