|
|
PHP header 的7种用法1. 跳转页面$ F1 q+ n& Z! c. }
header('Location:'.$url); //Location和":"之间无空格。
: Z. f8 V0 ^7 P2. 声明content-type
# v% ?" ^" a5 L5 w7 D0 H' v* xheader('content-type:text/html;charset=utf-8;charset=gbk');3. 返回response状态码6 {7 X: K; D" @6 [) [) N
header('HTTP/1.1 404 Not Found');4. 在某个时间后执行跳转
; {" ~$ T$ r0 Z% J, g" ]header('Refresh: 10; url=http://www.bbs168x.cn/'); //10s后跳转。5. 控制浏览器缓存. ]: v# W: F& g; n4 m. E8 V- o" u
1 ^5 f$ J1 q7 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验证 B! i: t5 V# T& `4 \
header('HTTP/1.1 401 Unauthorized');header('WWW-Authenticate: Basic realm="Top Secret"');
( l0 |7 u! G% e( h1 J7. 执行下载操作) r9 Q9 }9 z, }9 [3 i2 ` Y5 c
& e3 @! o3 n0 [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')); //设置内容长度7 B8 J5 C) Z! I1 z3 p6 f. i n
5 @" Z( t1 e* z3 [* E4 w! b7 ?
相关推荐:php header函数导出excel表格PHP header头部定义详解php header函数的用法总结以上就是PHP header()的7种用法的详细内容,更多请关注php中文网其它相关文章! |
|