分享PHP header函数使用教程


Posted in PHP onSeptember 05, 2013
<?php 
// fix 404 pages: 
header('HTTP/1.1 200 OK'); 
// set 404 header: 
header('HTTP/1.1 404 Not Found'); 
// set Moved Permanently header (good for redrictions) 
// use with location header 
header('HTTP/1.1 301 Moved Permanently'); 
// redirect to a new location: 
header('Location: http://www.example.org/'); 
// redrict with delay: 
header('Refresh: 10; url=http://www.example.org/'); 
print 'You will be redirected in 10 seconds'; 
// you could also use the HTML syntax:// <meta http-equiv="refresh" content="10;http://www.example.org/ /> 
// override X-Powered-By: PHP: 
header('X-Powered-By: PHP/4.4.0'); 
header('X-Powered-By: Brain/0.6b'); 
// content language (en = English) 
header('Content-language: en'); 
// last modified (good for caching) 
$time = time() ? 60; // or filemtime($fn), etc 
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); 
// header for telling the browser that the content 
// did not get changed 
header('HTTP/1.1 304 Not Modified'); 
// set content length (good for caching): 
header('Content-Length: 1234'); 
// Headers for an download: 
header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="example.zip"'); 
header('Content-Transfer-Encoding: binary'); 
// load the file to send:readfile('example.zip'); 
// Disable caching of the current document: 
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); 
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
// Date in the pastheader('Pragma: no-cache'); 
// set content type: 
header('Content-Type: text/html; charset=iso-8859-1'); 
header('Content-Type: text/html; charset=utf-8'); 
header('Content-Type: text/plain'); 
// plain text file 
header('Content-Type: image/jpeg'); 
// JPG picture 
header('Content-Type: application/zip'); 
// ZIP file 
header('Content-Type: application/pdf'); 
// PDF file 
header('Content-Type: audio/mpeg'); 
// Audio MPEG (MP3,…) file 
header('Content-Type: application/x-shockwave-flash'); 
// Flash animation// show sign in box 
header('HTTP/1.1 401 Unauthorized'); 
header('WWW-Authenticate: Basic realm="Top Secret"'); 
print 'Text that will be displayed if the user hits cancel or '; 
print 'enters wrong login data'; 
?>
PHP 相关文章推荐
PHP中的cookie
Nov 26 PHP
《PHP边学边教》(01.开篇――准备工作)
Dec 13 PHP
php 设计模式之 单例模式
Dec 19 PHP
php购物网站支付paypal使用方法
Nov 28 PHP
php 团购折扣计算公式
Nov 24 PHP
PHP 类相关函数的使用详解
May 10 PHP
thinkphp中连接oracle时封装方法无法用的解决办法
Jun 17 PHP
PHP设置一边执行一边输出结果的代码
Sep 30 PHP
php判断页面是否是微信打开的示例(微信打开网页)
Apr 25 PHP
php 无限级分类,超级简单的无限级分类,支持输出树状图
Jun 29 PHP
PHP实现打包zip并下载功能
Jun 12 PHP
php实现网页上一页下一页翻页过程详解
Jun 28 PHP
php增删改查示例自己写的demo
Sep 04 #PHP
php使用异或实现的加密解密实例
Sep 04 #PHP
PHP中数组定义的几种方法
Sep 01 #PHP
对淘宝URL中ID提取的PHP代码
Sep 01 #PHP
怎么在Windows系统中搭建php环境
Aug 31 #PHP
深入解析php中的foreach函数
Aug 31 #PHP
如何使用php输出时间格式
Aug 31 #PHP
You might like
用PHP实现登陆验证码(类似条行码状)
2006/10/09 PHP
php内嵌函数用法实例
2015/03/20 PHP
利用php抓取蜘蛛爬虫痕迹的示例代码
2016/09/30 PHP
php基于自定义函数记录log日志方法
2017/07/21 PHP
laravel 解决ajax异步提交数据,并还回填充表格的问题
2019/10/15 PHP
Sample script that deletes a SQL Server database
2007/06/16 Javascript
Chrome中模态对话框showModalDialog返回值问题的解决方法
2010/05/25 Javascript
form表单中去掉默认的enter键提交并绑定js方法实现代码
2013/04/01 Javascript
JavaScript获取路径设计源码
2014/05/22 Javascript
JavaScript用select实现日期控件
2015/07/17 Javascript
基于Vue.js实现简单搜索框
2020/03/26 Javascript
详解使用vue实现tab 切换操作
2017/07/03 Javascript
JS实现的找零张数最小问题示例
2017/11/28 Javascript
JS实现快递单打印功能【推荐】
2018/06/21 Javascript
[00:53]TI3正赛第三天 DK怒破A队不败金身 现场国旗飘扬热血激昂
2013/08/10 DOTA
Python3基础之条件与循环控制实例解析
2014/08/13 Python
使用Python写CUDA程序的方法
2017/03/27 Python
python算法表示概念扫盲教程
2017/04/13 Python
获取Django项目的全部url方法详解
2017/10/26 Python
Python多线程编程之多线程加锁操作示例
2018/09/06 Python
Python3 利用requests 库进行post携带账号密码请求数据的方法
2018/10/26 Python
Django1.11配合uni-app发起微信支付的实现
2019/10/12 Python
Python 获取numpy.array索引值的实例
2019/12/06 Python
python cv2截取不规则区域图片实例
2019/12/21 Python
pyecharts绘制中国2020肺炎疫情地图的实例代码
2020/02/12 Python
Python图像处理库PIL的ImageEnhance模块使用介绍
2020/02/26 Python
CSS3 input框的实现代码类似Google登录的动画效果
2020/08/04 HTML / CSS
Hotels.com拉丁美洲:从豪华酒店到经济型酒店的预定优惠和折扣
2019/12/09 全球购物
Ajax请求总共有多少种Callback
2016/07/17 面试题
毕业生毕业总结的自我评价范文
2013/11/02 职场文书
司机的工作范围及职责
2013/11/13 职场文书
求职信怎么写范文
2014/05/26 职场文书
2014年大堂经理工作总结
2014/11/21 职场文书
二手房购房意向书
2015/05/09 职场文书
2019年农民幸福观调查的实践感悟
2019/12/19 职场文书
CSS实现切角+边框+投影+内容背景色渐变效果
2021/11/01 HTML / CSS