发布:sunday01   来源:Net     【  】 转自:http://www.jbxue.com/article/6915.html
用于演示PHP header()函数用法的代码,介绍了refresh方法,老外写的,当然不会太差,有需要的朋友参考下吧。

php header头信息的例子。

<?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.jbxue.com/ />
// 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 header()函数的简单例子
php header函数实现文件下载的实例代码
php中header函数的用法举例详解
php 文件下载类(header头信息的应用实例)
php header 使用详解
php header函数 文件下载时直接提示保存的代码
php 文件头部(header)信息详解
PHP中HEADER头消息详解
php header函数使用要点

php header头信息 举例的更多相关文章

  1. curl get请求添加header头信息

    function get($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CU ...

  2. HTTP header头信息

    HTTP(HyperTextTransferProtocol)即超文本传输协议,目前网页传输的的通用协议.HTTP协议采用了请求/响应模型,浏览器或其他客户端发出请求,服务器给与响应.就整个网络资源传 ...

  3. nginx反向代理导致请求header头信息丢失

    背景:前端与后端调试接口,后端拿不到前段发过去的请求头信息,导致接口不通.(但是在本地是可以拿到的) 原因:nginx做了反向代理,没有请求时候加头信息的配置 报错如下: 解决方法: 方法一:NGIN ...

  4. Nginx 操作响应头信息的实现

    前置条件:需要编译 ngx_http_headers_module 模块,才支持 header 头信息操作 add_header 意思为将自定义的头信息的添加到响应头,指令为 add_header n ...

  5. 提取header头进行模块化处理

    在进行爬取网上东西的时候一般网站都做了UA的过滤,解决办法就是在代码中加入. 所以才有了本篇提取header头信息单独写成一个模块或者说是函数/类的想法,直接上示例 1.把UA头信息在浏览器中复制出来 ...

  6. PHP中header头设置Cookie与内置setCookie的区别

    首先声明,浏览的Cookie操作都是通过HTTP Header(俗称“Http头”) 来实现.所有的服务器与客户端之间Cookie数据传输都是通过Http请求头来操作. PHP中setCookie(函 ...

  7. Tomcat 中响应头信息(Http Response Header) Content-Length 和 Transfer-Encoding

    户端(PC浏览器或者手机浏览器)在接受到Tomcat的响应的时候,头信息通常都会带上Content-Length ,一般情况下客户端会在接受完Content-Length长度的数据之后才会开始解析.而 ...

  8. HTTP 响应头信息(Http Response Header) Content-Length 和 Transfer-Encoding

    Tomcat 中响应头信息(Http Response Header) Content-Length 和 Transfer-Encoding 客户端(PC浏览器或者手机浏览器)在接受到Tomcat的响 ...

  9. java中如何设置HTTP协议的头信息(header)

    首先,我们先看一下http的头信息到底是什么:HTTP(HyperTextTransferProtocol) 即超文本传输协议,目前网页传输的的通用协议.HTTP协议采用了请求/响应模型,浏览器或其他 ...

随机推荐

  1. BFS-hdu-1226-超级密码

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1226 题目意思: 给一个N,给nn个jj进制的数字,问最小的不超过500位的由这些数字组成的jj进制 ...

  2. iOS H5容器的一些探究(一):UIWebView和WKWebView的比较和选择

    一.Native开发中为什么需要H5容器 Native开发原生应用是手机操作系统厂商(目前主要是苹果的iOS和google的Android)对外界提供的标准化的开发模式,他们对于native开发提供了 ...

  3. js里一些经典的算法

    //1.找出某个数字在一组数组内的存不存在 如果存在 找出他所在的索引. function indexOf(arr,item){ var i; if(Array.prototype.indexOf){ ...

  4. zlib导致Ubuntu登录管理器失效

    ubuntu版本:10.04 现象:开机之后无法启动登录管理器. 原因:zlib与登录管理器冲突. 解决:卸载zlib.

  5. [转]Oracle hang分析

    hanganalyze是ORACLE的一款性能诊断工具,这个款工具是从oracle 8.0.6开始可用,在oracle数据库出现严重的性能问题的时候它可以帮助你定位问题所在. 1.首先说说hangan ...

  6. Objective-C ,ios,iphone开发基础:快速实现一个简单的图片查看器

    新建一个single view 工程: 关闭ARC , 在.xib视图文件上拖放一个UIImageView  两个UIButton ,一个UISlider ,布局如图. 并为他们连线, UIImage ...

  7. javaweb学习总结十四(xml约束之Schema)

    一:schema约束简单介绍 1:xml Schema的定义以及优缺点 2:xml schema入门 3:命名空间 这里http://www.itcast.cn 并没有什么具体的意义,只是命名而已. ...

  8. mysql导入数据load data infile用法

    mysql导入数据load data infile用法 基本语法: load data [low_priority] [local] infile 'file_name txt' [replace | ...

  9. hdu 4374 单调队列优化动态规划

    思路:我只想说,while(head<=rear&&que[rear].val+sum[j]-sum[que[rear].pos-1]<=dp[i-1][j]+num[i- ...

  10. Spring(3.2.3) - Beans(5): 集合属性的注入

    如果 Bean 的属性是个集合,则可以使用 <list/>.<set/>.<map/> 和 <props/> 元素向 List.Set.Map 和 Pr ...