一、可用作网页跳转 header("location:http://blog.csdn.net/zhaozzeng/");
二、
定义编码header( 'Content-Type:text/html;charset=utf-8 ');
三、强制禁止客户端浏览器缓存
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Cache-Control: no-cache");header("Pragma: no-cache");
四、输出页面表格header('Content-type: application/xls');
header('Content-Disposition: attachment; filename=文件名.xls');
echo $table(表格字符串)
五、以PDF格式下载当前页面header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename='文件名.pdf'");
六、输出json格式字符串
header('Content-Type: application/json; charset=utf-8');echo json_encode($array);
七、文件延迟转向:header('Refresh: 10; url=
http://blog.csdn.net/zhaozzeng/
');
八、提供简单的图片下载支持
url为绝对路径
header('Content-type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-length: '.filesize($url));
header('Content-disposition: attachment; filename='.basename($url));
readfile($url);
九、网页出错处理
// 301
header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,301); 、
// 302
header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,302);
// 303
header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,303);
// 307
header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,307);
// 404 header("Location:http://blog.csdn.net/zhaozzeng/",TRUE,404);
........