|
|
PHP header 的7种用法1. 跳转页面
( q K6 d7 F1 ~8 }& bheader('Location:'.$url); //Location和":"之间无空格。( R( T+ c7 ^' r/ _- A& x& O
2. 声明content-type; F( c/ w3 P7 I: s, z- ^ x+ w7 t
header('content-type:text/html;charset=utf-8;charset=gbk');3. 返回response状态码
( k+ l9 \/ j( r3 d" d: Nheader('HTTP/1.1 404 Not Found');4. 在某个时间后执行跳转4 H& h5 ^ [: u, \
header('Refresh: 10; url=http://www.bbs168x.cn/'); //10s后跳转。5. 控制浏览器缓存
. ?2 Q! I# ^. s7 c6 [* N$ }9 v; O5 `+ t
header("Expires: Ture, 31 2022 09:00:00 GMT");header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");header("Cache-Control: no-cache, must-revalidate");header("Pragma: no-cache");6. . 执行http验证! K6 _( {/ c! u) j6 K# I. T
header('HTTP/1.1 401 Unauthorized');header('WWW-Authenticate: Basic realm="Top Secret"');% O* P$ `! O" i3 H# }
7. 执行下载操作" Y8 T9 r8 f7 E1 \# z0 f
! j8 S3 F# e5 O, e7 V2 m% f( T
header('Content-Type: application/octet-stream'); //设置内容类型header('Content-Disposition: attachment; filename="example.zip"'); //设置MIME用户作为附件header('Content-Transfer-Encoding: binary'); //设置传输方式header('Content-Length: '.filesize('example.zip')); //设置内容长度$ n* y( p/ h0 t
. Q$ v9 T7 M* T相关推荐:php header函数导出excel表格PHP header头部定义详解php header函数的用法总结以上就是PHP header()的7种用法的详细内容,更多请关注php中文网其它相关文章! |
|