分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

php header

发布时间:2023-09-06 02:16责任编辑:董明明关键词:暂无标签

返回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后跳转

声明一个下载的文件

// 下载 zipheader(‘Content-Type: application/octet-stream‘); //设置内容类型header(‘Content-Disposition: attachment; filename="ITblog.zip"‘); //设置MIME用户作为附件header(‘Content-Transfer-Encoding: binary‘); //设置传输方式readfile(‘test.zip‘); // 打开文件,输出内容// 下载 execlheader(‘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

原文地址:https://www.cnblogs.com/xuey/p/9739459.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved