PHP所有常用的header头

// ok 正常访问header('HTTP/1.1 404 Not Found'); //通知浏览器 页面不存在
header('HTTP/1.1 200 OK'); 
//设置地址被永久的重定向 301
header('HTTP/1.1 301 Moved Permanently');
//跳转到一个新的地址
header('Location: http://php.itcast.cn/');
//延迟转向也就是隔几秒跳转
header('Refresh:10;url=http://php.itcast.cn/'); 

###内容类型###
//网页编码
header('Content-Type: text/html;charset=utf-8'); 
//纯文本格式
header('Content-Type:text/plain'); 
//JPG、JPEG
header('Content-Type:image/jpeg');
//ZIP文件
header('Content-Type:application/zip');
//PDF文件
header('Content-Type:application/pdf');
//音频文件
header('Content-Type: ');
//css文件
header('Content-type:text/css');

###声明一个下载的文件###
header('Content-Type:application/octet-stream');
header('Content-Disposition:attachment;filename="ITblog.zip"');

###显示一个需要验证的登陆对话框### header('HTTP/1.1 401Unauthorized');
header('WWW-Authenticate:Basic realm="TopSecret"');

###声明一个需要下载的xls文件###header('Content-Disposition: attachment; filename=ithhc.xlsx');header('Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');header('Content-Length:'.filesize('./test.xls'));
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章