系统类库
[ 查看开发文档 ] [ 类树图: Library ] [ 索引: Library ] [ 所有元素 ] [ 首页 ]

Class: Response

源文件路径: /Library/Response.class.php

Class Overview


系统响应类


Methods


Inherited Variables

Inherited Methods


Class Details

[line 9]
系统响应类


[ Top ]


Method Detail

__construct (Constructor)   [line 26]

Response __construct( Application $context)

构造函数(由容器调用)
  • Access: public

Parameters:

Application   $context   —  应用程序对象

[ Top ]

cookie   [line 96]

void cookie( $key, [ $value = ''], [ $expire = 0], [ $path = '/'], [ $domain = ''], [ $secure = 0], [ $httponly = 0])

设置HTTP响应的Header信息

Parameters:

   $key   — 
   $value   — 
   $expire   — 
   $path   — 
   $domain   — 
   $secure   — 
   $httponly   — 

[ Top ]

end   [line 203]

void end( [string $data = null], [bool $isAsyn = 0])

发送Http响应体,并结束请求处理
  • Access: public

Parameters:

string   $data   —  字符串数据
bool   $isAsyn   — 

是否使用异步输出,默认为false

说明:只能调用一次,如果需要分多次向客户端发送数据,请使用write方法


[ Top ]

flush   [line 164]

void flush( mixed $data, [string $dataType = ''], [string|bool $charset = ''])

输出数据到客户端并结束
  • Access: public

Parameters:

mixed   $data   —  需要输出的数据
string   $dataType   —  数据类型,可以是文件扩展名或类型标志(如:text/html)
string|bool   $charset   —  编码类型,默认为空使用系统配置,为false则不输出编码类型

[ Top ]

getContext   [line 34]

void getContext( )

获取上下文应用对象
  • Access: public

[ Top ]

gzip   [line 128]

void gzip( [int $level = 0])

压缩级别设置
  • Access: public

Parameters:

int   $level   — 

压缩等级,范围是1-9,等级越高压缩后的尺寸越小,但CPU消耗更多。默认为1

说明:启用Http GZIP压缩。压缩可以减小HTML内容的尺寸,有效节省网络带宽,提高响应时间。 必须在write/end发送内容之前执行gzip,否则会抛出错误


[ Top ]

hasSendHeader   [line 64]

bool hasSendHeader( )

判断是否成功发送请求头部信息
  • Access: public

[ Top ]

header   [line 80]

bool header( string $key, string $value, [bool $hasSend = true])

设置HTTP响应的Header信息
  • Return:

    | void

    说明:header设置必须在end方法之前,键名必须完全符合Http的约定, 每个单词首字母大写,不得包含中文,下划线或者其他特殊字符 header设置必须在end方法之前

  • Access: public

Parameters:

string   $key   —  http头的键名
string   $value   —  http头的键值
bool   $hasSend   —  是否设置为已发送,默认为true

[ Top ]

redirect   [line 233]

void redirect( string $url, [int $time = 0], [string $msg = ''])

URL重定向
  • Access: public

Parameters:

string   $url   —  重定向的URL地址
int   $time   —  重定向的等待时间(秒)
string   $msg   —  重定向前的提示信息

[ Top ]

sendfile   [line 180]

void sendfile( string $filename, [int $offset = 0], [int $length = 0])

发送文件到浏览器
  • Access: public

Parameters:

string   $filename   —  要发送的文件名称
int   $offset   —  上传文件的偏移量,可以指定从文件的中间部分开始传输数据。此特性可用于支持断点续传
int   $length   — 

发送数据的尺寸,默认为整个文件的尺寸

说明:调用sendfile前不得使用write方法发送Http-Chunk


[ Top ]

setIsEnd   [line 55]

void setIsEnd( [boolean $status = true])

设置是否请求结束
  • Access: public

Parameters:

boolean   $status   —  是否请求结束,默认:true

[ Top ]

setResponse   [line 43]

void setResponse( [Response $response = null])

设置外部响应对象
  • Access: public

Parameters:

Response   $response   —  外部响应对象

[ Top ]

status   [line 112]

void status( int $code)

发送Http状态码
  • Access: public

Parameters:

int   $code   — 

状态码

说明:$http_status_code必须为合法的HttpCode,如200, 502, 301, 404等,否则会报错 必须在$response->end之前执行status


[ Top ]

write   [line 139]

void write( string $data, [string $dataType = ''], [string|bool $charset = ''])

启用Http Chunk分段向浏览器发送相应内容
  • Access: public

Parameters:

string   $data   —  要发送的数据内容,最大长度不得超过2M
string   $dataType   —  数据类型,可以是文件扩展名或类型标志(如:text/html)
string|bool   $charset   —  编码类型,默认为空使用系统配置,为false则不输出编码类型

[ Top ]


Powered by Steeze. author email: spring.wind2006@163.com