Response
in package
Tags
Table of Contents
- $instance : object
- Response instance
- $mimeTypes : array<string|int, mixed>
- $statusDescriptions : array<string|int, mixed>
- $content : string
- 输出内容
- $contentType : string
- 返回头http类型
- $cookie : array<string|int, mixed>
- cookie
- $cookieConfig : array<string|int, mixed>
- cookie配置
- $endFlush : bool
- 停止发送标识
- $header : array<string|int, mixed>
- http头
- $responseStatus : int
- http 状态代码
- $responseStatusReason : string
- addHeader() : Response
- 添加header
- basicAuth() : void
- basic authentication
- cookieConfig() : self
- 设置cookie参数默认值 <pre> 参数为一个数组, 支持以下参数
- deleteCookie() : self
- 删除cookie
- digestAuth() : void
- digest authentication
- end() : void
- 输出内容并添加停止标识
- getContent() : string
- 输出内容
- getContentType() : string
- 返回ContentType
- getCookie() : array<string|int, mixed>
- 获取cookie
- getHeader() : array<string|int, mixed>
- header
- getInstance() : static
- 单例模式
- isEndFlush() : bool
- 获取标识状态,是否终止输出
- redirect() : void
- 重定向
- send() : void
- 输出内容
- setContent() : self
- 设置输出内容
- setContentType() : self
- 设置返回头类型
- setCookie() : self
- 添加Cookie
- setEndFlush() : Response
- 标识停止Send
- setRawContent() : self
- 设置输出内容(不限制类型,带模板)
- setRawCookie() : $this
- 添加PHP原生Cookie
- setResponseStatus() : self
- 设置response状态
- getCookieConfig() : mixed
- 获取cookie参数默认值
- __construct() : mixed
- httpDigestParse() : array<string|int, mixed>|bool
- Parse digest authentication string
- sendContentType() : void
- 发送ContentType
- sendCookie() : void
- 发送cookie
- sendHeader() : void
- 发送header
- sendResponseStatus() : void
- 发送http 状态码
Properties
$instance
Response instance
public
static object
$instance
$mimeTypes
public
static array<string|int, mixed>
$mimeTypes
= ['ez' => 'application/andrew-inset', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'class' => 'application/octet-stream', 'so' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'bcpio' => 'application/x-bcpio', 'vcd' => 'application/x-cdlink', 'pgn' => 'application/x-chess-pgn', 'cpio' => 'application/x-cpio', 'csh' => 'application/x-csh', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'spl' => 'application/x-futuresplash', 'gtar' => 'application/x-gtar', 'hdf' => 'application/x-hdf', 'js' => 'application/x-javascript', 'json' => 'application/json', 'skp' => 'application/x-koan', 'skd' => 'application/x-koan', 'skt' => 'application/x-koan', 'skm' => 'application/x-koan', 'latex' => 'application/x-latex', 'nc' => 'application/x-netcdf', 'cdf' => 'application/x-netcdf', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texinfo' => 'application/x-texinfo', 'texi' => 'application/x-texinfo', 't' => 'application/x-troff', 'tr' => 'application/x-troff', 'roff' => 'application/x-troff', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'ms' => 'application/x-troff-ms', 'ustar' => 'application/x-ustar', 'src' => 'application/x-wais-source', 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', 'zip' => 'application/zip', 'au' => 'audio/basic', 'snd' => 'audio/basic', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'kar' => 'audio/midi', 'mpga' => 'audio/mpeg', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'm3u' => 'audio/x-mpegurl', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'pdb' => 'chemical/x-pdb', 'xyz' => 'chemical/x-xyz', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'ief' => 'image/ief', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'djvu' => 'image/vnd.djvu', 'djv' => 'image/vnd.djvu', 'wbmp' => 'image/vnd.wap.wbmp', 'ras' => 'image/x-cmu-raster', 'pnm' => 'image/x-portable-anymap', 'pbm' => 'image/x-portable-bitmap', 'pgm' => 'image/x-portable-graymap', 'ppm' => 'image/x-portable-pixmap', 'rgb' => 'image/x-rgb', 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'igs' => 'model/iges', 'iges' => 'model/iges', 'msh' => 'model/mesh', 'mesh' => 'model/mesh', 'silo' => 'model/mesh', 'wrl' => 'model/vrml', 'vrml' => 'model/vrml', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'asc' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'sgml' => 'text/sgml', 'sgm' => 'text/sgml', 'tsv' => 'text/tab-separated-values', 'wml' => 'text/vnd.wap.wml', 'wmls' => 'text/vnd.wap.wmlscript', 'etx' => 'text/x-setext', 'xsl' => 'text/xml', 'xml' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'mxu' => 'video/vnd.mpegurl', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'ice' => 'x-conference/x-cooltalk']
$statusDescriptions
public
static array<string|int, mixed>
$statusDescriptions
= [100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported']
$content
输出内容
protected
string
$content
= ''
$contentType
返回头http类型
protected
string
$contentType
$cookie
cookie
protected
array<string|int, mixed>
$cookie
= []
$cookieConfig
cookie配置
protected
array<string|int, mixed>
$cookieConfig
= []
$endFlush
停止发送标识
protected
bool
$endFlush
= false
$header
http头
protected
array<string|int, mixed>
$header
= []
$responseStatus
http 状态代码
protected
int
$responseStatus
= 200
$responseStatusReason
protected
string
$responseStatusReason
Methods
addHeader()
添加header
public
addHeader(string $key, string $value) : Response
Parameters
- $key : string
- $value : string
Return values
Response —basicAuth()
basic authentication
public
basicAuth(array<string|int, mixed> $users, string $user, string $password[, array<string|int, mixed> $options = [] ]) : void
Parameters
- $users : array<string|int, mixed>
-
['user' => 'password']
- $user : string
-
PHP_AUTH_USER
- $password : string
-
PHP_AUTH_PW
- $options : array<string|int, mixed> = []
Return values
void —cookieConfig()
设置cookie参数默认值 <pre> 参数为一个数组, 支持以下参数
public
cookieConfig(array<string|int, mixed> $config) : self
path 默认为空字符串 domain 默认为空字符串 secure 默认为false httponly 默认为true
Parameters
- $config : array<string|int, mixed>
Return values
self —deleteCookie()
删除cookie
public
deleteCookie(string $name) : self
Parameters
- $name : string
Return values
self —digestAuth()
digest authentication
public
digestAuth(array<string|int, mixed> $users, string $digest, string $requestMethod[, array<string|int, mixed> $options = [] ]) : void
Parameters
- $users : array<string|int, mixed>
-
['user' => 'password']
- $digest : string
-
PHP_AUTH_DIGEST
- $requestMethod : string
-
REQUEST_METHOD
- $options : array<string|int, mixed> = []
Return values
void —end()
输出内容并添加停止标识
public
end() : void
Return values
void —getContent()
输出内容
public
getContent() : string
Return values
string —getContentType()
返回ContentType
public
getContentType() : string
Return values
string —getCookie()
获取cookie
public
getCookie() : array<string|int, mixed>
Return values
array<string|int, mixed> —getHeader()
header
public
getHeader() : array<string|int, mixed>
Return values
array<string|int, mixed> —getInstance()
单例模式
public
static getInstance() : static
Return values
static —isEndFlush()
获取标识状态,是否终止输出
public
isEndFlush() : bool
Return values
bool —redirect()
重定向
public
redirect(string $url[, int $status = 302 ]) : void
Parameters
- $url : string
- $status : int = 302
Return values
void —send()
输出内容
public
send() : void
Return values
void —setContent()
设置输出内容
public
setContent(string $content) : self
Parameters
- $content : string
Return values
self —setContentType()
设置返回头类型
public
setContentType(string $type) : self
Parameters
- $type : string
Return values
self —setCookie()
添加Cookie
public
setCookie(string $name[, mixed $value = '' ], int $expire) : self
Parameters
- $name : string
- $value : mixed = ''
- $expire : int
Return values
self —setEndFlush()
标识停止Send
public
setEndFlush(bool $status) : Response
Parameters
- $status : bool
Return values
Response —setRawContent()
设置输出内容(不限制类型,带模板)
public
setRawContent(mixed $content[, string|null $tpl = null ]) : self
Parameters
- $content : mixed
- $tpl : string|null = null
Return values
self —setRawCookie()
添加PHP原生Cookie
public
setRawCookie(string $name[, mixed $value = '' ], int $expire[, string $path = '' ][, string $domain = '' ]) : $this
Parameters
- $name : string
- $value : mixed = ''
- $expire : int
- $path : string = ''
- $domain : string = ''
Return values
$this —setResponseStatus()
设置response状态
public
setResponseStatus(int $status[, string $reason = null ]) : self
Parameters
- $status : int
- $reason : string = null
Return values
self —getCookieConfig()
获取cookie参数默认值
protected
getCookieConfig(string $key) : mixed
Parameters
- $key : string
Return values
mixed —__construct()
private
__construct() : mixed
Return values
mixed —httpDigestParse()
Parse digest authentication string
private
httpDigestParse(string $txt) : array<string|int, mixed>|bool
Parameters
- $txt : string
Return values
array<string|int, mixed>|bool —sendContentType()
发送ContentType
private
sendContentType() : void
Return values
void —sendCookie()
发送cookie
private
sendCookie() : void
Return values
void —sendHeader()
发送header
private
sendHeader() : void
Return values
void —sendResponseStatus()
发送http 状态码
private
sendResponseStatus() : void