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"');

猜你喜欢

转载自blog.csdn.net/weixin_43524620/article/details/84101526