|
|
PHP header 的7种用法1. 跳转页面! K8 C" H9 k: `
header('Location:'.$url); //Location和":"之间无空格。3 V2 U% b: ~6 x7 P/ c( d
2. 声明content-type B" e1 h9 s4 H( x0 D2 Y! ~& D' v
header('content-type:text/html;charset=utf-8;charset=gbk');3. 返回response状态码& O6 k4 \- j1 N/ c; v
header('HTTP/1.1 404 Not Found');4. 在某个时间后执行跳转
7 A( Y+ i* D4 P) ?header('Refresh: 10; url=http://www.bbs168x.cn/'); //10s后跳转。5. 控制浏览器缓存
* ^1 `+ {& P. V1 x4 F& c3 n! L% l5 L# Y3 e
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验证
" f% z/ o7 S+ |. U) o- Sheader('HTTP/1.1 401 Unauthorized');header('WWW-Authenticate: Basic realm="Top Secret"');
& B5 e& J7 S% W+ U7. 执行下载操作) Y5 ^; X7 u% q
3 }* S3 p0 ]4 n6 m# K& V+ uheader('Content-Type: application/octet-stream'); //设置内容类型header('Content-Disposition: attachment; filename="example.zip"'); //设置MIME用户作为附件header('Content-Transfer-Encoding: binary'); //设置传输方式header('Content-Length: '.filesize('example.zip')); //设置内容长度
$ j% q6 d6 ?" h. N% f H
k4 R8 p) S! d2 k/ M0 I相关推荐:php header函数导出excel表格PHP header头部定义详解php header函数的用法总结以上就是PHP header()的7种用法的详细内容,更多请关注php中文网其它相关文章! |
|