发布: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. 小白日记15:kali渗透测试之弱点扫描-漏扫三招、漏洞管理、CVE、CVSS、NVD

    发现漏洞 弱点发现方法: 1.基于端口服务扫描结果版本信息,比对其是否为最新版本,若不是则去其 官网查看其补丁列表,然后去逐个尝试,但是此法弊端很大,因为各种端口应用比较多,造成耗时大. 2.搜索已公 ...

  2. Sqlite和CoreData的区别

    使用方便性.实际上,一个成熟的工程中一定是对数据持久化进行了封装的,因此底层使用的到底是core data还是sqlite,不应该被业务逻辑开发者关心.因此,即使习惯写SQL查询的人,也应该避免在业务 ...

  3. android文件系统挂载分析(1)---正常开机挂载

    未完,更新中 ... "android"系列分为三部分: 1.正常开机挂载 2.encryption 3.dm-verity 我们知道android有很多分区,如"sys ...

  4. python(5)–sys模块

    sys.argv 命令行参数list, 第一个元素是程序本身路径 sys.exit(n) 退出程序,退出时输入信息n sys.version 获取python解释程序的版本信息 sys.maxint ...

  5. windows下使用VirtualEnv

    在开发Python应用程序的时候,有时会开发多个应用程序,那这些应用程序都会共用一个Python.如果应用A需要jinja 2.7,而应用B需要jinja 2.6怎么办?这种情况下,每个应用可能需要各 ...

  6. css3 颜色记

    css3 颜色 opacity 使元素呈现出半透明效果. opacity:alphavalue || inherit alphavalue:默认值为1,可以取0~1任意浮点数.取值为1时,元素完全不透 ...

  7. JS的第一节课

    javascript中有两个非常重要的数据类型是对象和数组. e.g: var book={ topic:"javascript", fat:true };

  8. C++函数学习笔记

    C++继承了C语言的全部语法,也包括函数的定义和使用方法. 调用其他函数的函数因为位高权重被尊称为主调函数,被其他函数调用的函数称为被调函数. 函数的返回值由return语句给出,return 表达式 ...

  9. Jersey(1.19.1) - Client API, Security with Http(s)URLConnection

    With Http(s)URLConnection The support for security, specifically HTTP authentication and/or cookie m ...

  10. 【TOMCAT】Tomcat gzip压缩传输数据

    概述 由于我们项目的三维模型文件非常大,为了提高传输速度,在服务端对其做zip压缩处理非常有必要,能够极大的提高传输速度. 配置 首先需要修改web.xml中请求的数据文件的mime类型的mappin ...