发布: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. B - Plane of Tanks: Pro

    Description Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to ...

  2. Peter's Hobby

    Problem Description Recently, Peter likes to measure the humidity of leaves. He recorded a leaf humi ...

  3. 乐在其中设计模式(C#) - 单例模式(Singleton Pattern)【转】

    介绍 保证一个类仅有一个实例,并提供一个访问它的全局访问点. 示例 保证一个类仅有一个实例. Singleton using System; using System.Collections.Gene ...

  4. python(3)-计数器,有序字典

    计数器:Counter 在使用计数器之前需要先 import collections >>> import collections >>> obj = collec ...

  5. linux配置LAMP

    VPS注意:最近在VPS安装过程中,MYSQL老是报错 dpkg: error processing package mysql-server-5.6 (--configure): subproces ...

  6. P6Spy 、 SQL Profiler

    P6Spy 在优化Hibernate性能的时候,很重要的一点就是要看到Hibernate底层执行的SQL 虽然通过打印日志配合Hibernate的show_sql属性能够拼凑出Hibernate底层执 ...

  7. HBase的JavaAPI操作

    如果是DDL的操作就找HbaseAdmin. 如果是表上的增删改查的操作就找HTable. 附录代码: mport java.util.Arrays; import org.apache.hadoop ...

  8. [改善Java代码]覆写变长方法也循规蹈矩

    建议6:覆写变长方法也循规蹈矩 在Java中,子类覆写父类中的方法很常见,这样做既可以修正Bug也可以提供扩展的业务功能支持,同时还符合开闭原则(Open-Closed Principle),我们来看 ...

  9. 2013 南京理工大学邀请赛B题

    思路: 每次枚举删除一个点,然后对剩下的点求出关键点,判断删除哪个关键点获得的连通分支数最大. #include<iostream> #include<cstdio> #inc ...

  10. Unity3D 之暂停和继续的实现

    Time.timeScale 时间缩放 当timeScale传递时间1.0时和实时时间一样快.当timeScale传递时间0.5时比实时时间慢一半. 当timeScale传递时间为0时游戏基本上暂停了 ...