<?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. HTML5要点(二)

    <p> <b>今天周一</b>,<span>呵呵呵呵呵...</span> </p> <i>斜体文字</i&g ...

  2. 网站WAF的检测

    [wafw00f]: 项目地址: https://github.com/sandrogauci/wafw00f WAFW00F是识别和指纹Web应用防火墙(WAF)产品,其工作原理是首先通过发送一个正 ...

  3. eclipse创建maven模块工程

    创建maven模块项目,可以使用eclipse工具来完成. 1.创建父工程,注意,要选择maven-archetype-site-simple new --> maven project 填写项 ...

  4. eclipse反编译插件

    eclipse翻译的插件很多,jadclipse 是其中一款.设置很简单. ①.下载net.sf.jadclipse_3.3.0.jar 官方网站:http://sourceforge.net/pro ...

  5. SCO连接SCOM报警

    当SCOM中出现红色警报时,在目标计算机上运行一个程序: 1.新建Runbook,添加一个Monitor Alert 2.设置Monitor Alert属性,选择connection,设置警报过滤条件 ...

  6. UVa 131 - The Psychic Poker Player

    题目:手里有五张牌,桌上有一堆牌(五张).你能够弃掉手中的k张牌,然后从牌堆中取最上面的k个. 比較规则例如以下:(按优先级排序) 1.straight-flush:同花顺.牌面为T(10) - A, ...

  7. Mac Pro更换SSD后,在Win7下启用ACHI的方法AHCI

    在Mac Pro下更换SSD后,如果安装Win7,要将SSD改为AHCI模式是非常麻烦的.本文介绍如何将Mac的Win7下的SSD改为AHCI方式驱动,及几种常见问题的处理. 一.当Lion与Win7 ...

  8. 每天进步一点点——负载均衡之DNS域名解析

    转载请说明出处:http://blog.csdn.net/cywosp/article/details/38017027     在上一篇文章(http://blog.csdn.net/cywosp/ ...

  9. pomelo windows 安装笔记

    1.安装nodejs http://nodejs.org/download/...这个简单.. 2.下载pomelo..并且 安装所需要的包.未能加载visual c++组件 “VCBuild.exe ...

  10. mysqldump原理3

    现网中数据库运维时,要经常对数据库做热备.为保证恢复时数据的完整性与一致性, 一种方法是在备份之前锁表,但锁表会影响正在运行的业务. mysqldump是当前MySQL中最常用的备份工具,通过mysq ...