首页 / PHP / php header
php header
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php header,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1695字,纯文字阅读大概需要3分钟。
内容图文
![php header](/upload/InfoBanner/zyjiaocheng/855/62941980684649f286af7cd1ca79300f.jpg)
返回response状态码
header('HTTP/1.1 200 OK'); // ok 正常访问 header('HTTP/1.1 404 Not Found'); //通知浏览器 页面不存在 header('HTTP/1.1 301 Moved Permanently'); //设置地址被永久的重定向 301
header('HTTP/1.1 304 Not Modified'); //告诉浏览器文档内容没有发生改变
设置修改 X-Powered-By信息
header('X-Powered-By: PHP/6.0.0');
文档语言
header('Content-language: en');
内容长度
header('Content-Length: 1024');
内容类型
header('Content-Type: text/html; charset=utf-8'); //网页格式,网页编码 header('Content-Type: text/plain'); //纯文本格式
设置浏览器最后一次修改时间
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
对当前文档禁用缓存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache");
显示一个需要验证的登陆对话框
header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Basic realm="Top Secret"');
跳转页面
header('Location:'.$url); //Location和":"之间无空格 header('Refresh: 10; url=http://www.baidu.com/'); //10s后跳转
声明一个下载的文件
// 下载 zip header('Content-Type: application/octet-stream'); //设置内容类型 header('Content-Disposition: attachment; filename="ITblog.zip"'); //设置MIME用户作为附件 header('Content-Transfer-Encoding: binary'); //设置传输方式 readfile('test.zip'); // 打开文件,输出内容 // 下载 execl header('Content-Disposition: attachment; filename=ithhc.xlsx'); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Length: '.filesize('./test.xls')); //设置内容长度 header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate'); header('Pragma: public'); // 任何人都可访问 readfile('./test.xls');
内容总结
以上是互联网集市为您收集整理的php header全部内容,希望文章能够帮你解决php header所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。