<?php
/*** Function: PHP header() examples (PHP)
** Desc: Some examples on how to use the header() function of PHPYou find a detailed tutorial at expertsrt.com (English) or at ffm.junetz.de (German).These is also a good help about caching at web-caching.com.
** Example: see below. <br/><br/><b>Tip:</b> You can use these sites to check your headers: <a href="http://web-sniffer.net/">web-sniffer.net</a>, <a href="http://www.delorie.com/web/headers.html">delorie.com</a> or <a href="http://www.forret.com/projects/analyze/">www.forret.com</a>.
** Author: Jonas John
*/ // 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 header示例代码(推荐)的更多相关文章

  1. C/C++ 开源库及示例代码

    C/C++ 开源库及示例代码 Table of Contents 说明 1 综合性的库 2 数据结构 & 算法 2.1 容器 2.1.1 标准容器 2.1.2 Lockfree 的容器 2.1 ...

  2. 50.AngularJs directive详解及示例代码

    转自:https://www.cnblogs.com/best/tag/Angular/ 本教程使用AngularJs版本:1.5.3 AngularJs GitHub: https://github ...

  3. ActiveMQ笔记(1):编译、安装、示例代码

    一.编译 虽然ActiveMQ提供了发布版本,但是建议同学们自己下载源代码编译,以后万一有坑,还可以尝试自己改改源码. 1.1 https://github.com/apache/activemq/r ...

  4. 股票数据调用示例代码php

    <!--?php // +---------------------------------------------------------------------- // | JuhePHP ...

  5. 正则表达式学习笔记(附:Java版示例代码)

    具体学习推荐:正则表达式30分钟入门教程 .         除换行符以外的任意字符\w      word,正常字符,可以当做变量名的,字母.数字.下划线.汉字\s        space,空白符 ...

  6. C# 6新特性及示例代码

    今天推荐的其实是一个Github开源项目,不过这个开源项目是专门介绍C# 6的最新特性,并给出了示例代码. 我们知道,微软即将发布Windows 10和Visual Studio 2015,在VS20 ...

  7. python开源项目及示例代码

    本页面是俺收集的各种 Python 资源,不定期更新. 下面列出的各种 Python 库/模块/工具,如果名称带超链接,说明是第三方的:否则是 Python 语言内置的. 1 算法 1.1 字符串处理 ...

  8. 看完48秒动画,让你不敢再登录HTTP网站(附完整示例代码)

    在我的 单点登录SSO示例代码 一文中,强烈不建议部署HTTP的SSO服务站点. 在此写个基于网络包嗅探的HTTP会话劫持程序,给大家一个直观的危害性展示. 示例中,我在一台Mac上登录58同城,被另 ...

  9. python开源项目及示例代码(转)

    本页面是俺收集的各种 Python 资源,不定期更新. 下面列出的各种 Python 库/模块/工具,如果名称带超链接,说明是第三方的:否则是 Python 语言内置的. 1 算法 1.1 字符串处理 ...

随机推荐

  1. Jsp的三、七、九

    1.jsp的三个编译指令 <%page %> <%taglib %> <%include %> 2.jsp的七个动作指令 forward param include ...

  2. Asp.Net事务和异常处理:

    Asp.Net事务和异常处理: 一.什么是事务处理? 事务处理是一组组和成逻辑工作单元的数据库操作,虽然系统中可能会出错,但事务将控制和维护每个数据库的一致性和完整性. 如果在事务过程中没有遇到错误, ...

  3. vs2005升级到vs2010相关问题

    1.项目编译失败,报 Resgen.exe 退出 ,错误代码2 处理方式: http://jingyan.baidu.com/article/90895e0fe80c6064ed6b0b6b.html ...

  4. 查看SQL语句执行时间、IO开销

    SET STATISTICS TIME ON SET STATISTICS IO ON或者set statistics io,time on

  5. URL是否有效

    unit Unit1;interfaceuses    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Syste ...

  6. HT518V311

    HT518V311.rar

  7. iOS开发——新特性OC篇&IOS9 SDK新特性

    iOS9 SDK新特性 WWDC 2015苹果开发者大会是移动开发者一年一度的盛会,InfoQ中文站除了第一时间整理Keynote内容分享给大家之外,还邀请了资深的一线开发者分享他们的收获.本文为王巍 ...

  8. MySQL 中的两种临时表

    来源:阿里云RDS - 数据库内核组 链接:http://mysql.taobao.org/monthly/2016/06/07/ 外部临时表 通过CREATE TEMPORARY TABLE 创建的 ...

  9. chrome浏览器更新到chrome 29.0.1547.76 m,多出一些蛋疼的功能来。

    更新到chrome 29.0.1547.76 m 的时候,莫名其妙多出一些蛋疼的功能来. 1.alert之类的弹出对话框样式变了,并且位置不是居中的,跑到了最上面去了,如下图. 要把这对话框改回原始状 ...

  10. java_TreeSet 定制排序实例

    package ming; import java.util.Comparator; import java.util.TreeSet; class M { int age; public M(int ...