Response

框架中对响应的操作封装在Response类中。

操作方法:

write

Response::write(string $str, Mime $mime) 
文本输出 ,输出后退出此次请求

Parameters: 
string $str 要输出的字串 
Mime $mime 要输出mime类型默认为:html

Mime类中定义了常用的Mime类型,他们是:

public static $hqx = 'application/mac-binhex40';
public static $cpt = 'application/mac-compactpro';
public static $csv = array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream');
public static $bin = 'application/macbinary';
public static $dms = 'application/octet-stream';
public static $lha = 'application/octet-stream';
public static $lzh = 'application/octet-stream';
public static $exe = array('application/octet-stream', 'application/x-msdownload');
public static $class = 'application/octet-stream';
public static $psd = 'application/x-photoshop';
public static $so = 'application/octet-stream';
public static $sea = 'application/octet-stream';
public static $dll = 'application/octet-stream';
public static $oda = 'application/oda';
public static $pdf = array('application/pdf', 'application/x-download');
public static $ai = 'application/postscript';
public static $eps = 'application/postscript';
public static $ps = 'application/postscript';
public static $smi = 'application/smil';
public static $smil = 'application/smil';
public static $mif = 'application/vnd.mif';
public static $xls = array('application/excel', 'application/vnd.ms-excel', 'application/msexcel');
public static $ppt = array('application/powerpoint', 'application/vnd.ms-powerpoint');
public static $wbxml = 'application/wbxml';
public static $wmlc = 'application/wmlc';
public static $dcr = 'application/x-director';
public static $dir = 'application/x-director';
public static $dxr = 'application/x-director';
public static $dvi = 'application/x-dvi';
public static $gtar = 'application/x-gtar';
public static $gz = 'application/x-gzip';
public static $php = array('application/x-httpd-php', 'text/x-php');
public static $php4 = 'application/x-httpd-php';
public static $php3 = 'application/x-httpd-php';
public static $phtml = 'application/x-httpd-php';
public static $phps = 'application/x-httpd-php-source';
public static $js = 'application/x-javascript';
public static $swf = 'application/x-shockwave-flash';
public static $sit = 'application/x-stuffit';
public static $tar = 'application/x-tar';
public static $tgz = array('application/x-tar', 'application/x-gzip-compressed');
public static $xhtml = 'application/xhtml+xml';
public static $xht = 'application/xhtml+xml';
public static $zip = array('application/x-zip', 'application/zip', 'application/x-zip-compressed');
public static $mid = 'audio/midi';
public static $midi = 'audio/midi';
public static $mpga = 'audio/mpeg';
public static $mp2 = 'audio/mpeg';
public static $mp3 = array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3');
public static $aif = 'audio/x-aiff';
public static $aiff = 'audio/x-aiff';
public static $aifc = 'audio/x-aiff';
public static $ram = 'audio/x-pn-realaudio';
public static $rm = 'audio/x-pn-realaudio';
public static $rpm = 'audio/x-pn-realaudio-plugin';
public static $ra = 'audio/x-realaudio';
public static $rv = 'video/vnd.rn-realvideo';
public static $wav = 'audio/x-wav';
public static $bmp = 'image/bmp';
public static $gif = 'image/gif';
public static $jpeg = array('image/jpeg', 'image/pjpeg');
public static $jpg = array('image/jpeg', 'image/pjpeg');
public static $jpe = array('image/jpeg', 'image/pjpeg');
public static $png = 'image/png';
public static $tiff = 'image/tiff';
public static $tif = 'image/tiff';
public static $css = 'text/css';
public static $html = 'text/html';
public static $htm = 'text/html';
public static $shtml = 'text/html';
public static $txt = 'text/plain';
public static $text = 'text/plain';
public static $log = array('text/plain', 'text/x-log');
public static $rtx = 'text/richtext';
public static $rtf = 'text/rtf';
public static $xml = 'text/xml';
public static $xsl = 'text/xml';
public static $mpeg = 'video/mpeg';
public static $mpg = 'video/mpeg';
public static $mpe = 'video/mpeg';
public static $qt = 'video/quicktime';
public static $mov = 'video/quicktime';
public static $avi = 'video/x-msvideo';
public static $movie = 'video/x-sgi-movie';
public static $doc = 'application/msword';
public static $docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
public static $xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
public static $word = array('application/msword', 'application/octet-stream');
public static $xl = 'application/excel';
public static $eml = 'message/rfc822';
public static $json = array('application/json', 'text/json');

json

Response::json($arr) 
json输出 ,输出后退出此次请求

Parameters: 
array $arr 要输出的数组

exejs

Response::exejs(string $jscode) 
客户端直接执行JS语句!!!此方法只在加载了视图文件的情况下可用
所添加的JS代码会在页面前期初始化工作完成之后执行

Parameters: 
string $jscode 要执行的JS脚本

download

Response::download(string $filename, mixed $content, Mime $mime) 
准备为客户端进行文件下载

Parameters: 
string $filename 客户端下载的文件名 
mixed $content 客户端下载的文件内容,如不传入则把这次请求的实际相应内容作为文件内容 
Mime $mime 要输出mime类型默认为:APPLICATION