发布: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. 基于ActiveMQ的统一日志服务

    概述 以ActiveMQ + Log4j + Spring的技术组合,实现基于消息队列的统一日志服务. 参考:Spring+Log4j+ActiveMQ实现远程记录日志——实战+分析 与参考文章的比较 ...

  2. hadoop实例---多表关联

    多表关联和单表关联类似,它也是通过对原始数据进行一定的处理,从其中挖掘出关心的信息.如下 输入的是两个文件,一个代表工厂表,包含工厂名列和地址编号列:另一个代表地址表,包含地址名列和地址编号列.要求从 ...

  3. org.apache.hadoop.fs-BufferedFSInputStream

    封装了FSInputStream package org.apache.hadoop.fs; import java.io.BufferedInputStream; import java.io.IO ...

  4. 《sift算法详解》阅读笔记

    原博客来自:http://blog.csdn.net/zddblog/article/details/7521424 定义: 尺度不变特征转化是一种计算机视觉算法,用于侦测和描述物体的局部性特征,在空 ...

  5. python(1) - 条件判断和循环

    条件判断: 比如输入用户年龄,根据年龄打印不同的内容,在python中用if语句实现: age = 20 if age >= 18: print('你可以看这个视频!') 可以给if加一个els ...

  6. Android 自学之网格试图(GridView)和图片切换器(ImageSwitcher)功能和用法

    网格试图(GridView)用于在界面上按行,列分布的方式来显示多个组件. GridView和ListView有共同的父类:AbsListView,因此GridView和ListView具有一定的相似 ...

  7. LeetCode 342

    Power of Four Given an integer (signed 32 bits), write a function to check whether it is a power of ...

  8. [改善Java代码]建议采用的顺序是 List<T>、List<?>、List<Object>

    建议98:建议采用的顺序是 List<T>.List<?>.List<Object> List<T>.List<?>.List<Obj ...

  9. IOC容器初始化过程

    原文链接请参见:http://blog.csdn.net/u010723709/article/details/47046211

  10. Hibernate常见面试题

    1.什么是Hibernate的并发机制?怎么去处理并发问题? Hibernate并发机制: a.Hibernate的Session对象是非线程安全的,对于单个请求,单个会话,单个的工作单元(即单个事务 ...