php header函数实例代码
其中介绍的refresh方法,比<META ……用起来更得心应手,应该是段不错的代码。
<?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.jbxue.com/web/headers.html">jbxue.com</a> or <a href="http://www.jbxue.com/projects/analyze/">www.jbxue.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.jbxue.com/'); // redrict with delay:
header('Refresh: 10; url=http://www.jbxue.com/');
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全角字符转换为半角函数 实例代码
PHP全角半角转换函数,把目前能找到的所有全角都列出来了一个个替换吧. 之前试过网上找的通过ASCII之类的字符替换,发现很多莫名其妙的问题.最后还是换成下面的字符替换方式了,把目前能找到的所有全角都 ...
- select函数实例代码
select函数简解: selct 称之为多路复用IO,使用它可以让程序阻塞在select上,而非实际IO函数上. int select(int nfds, fd_set *readfds, fd_s ...
- php随机密码函数的实例代码
php随机密码函数的入门例子 时间:2015-12-16 20:42:48来源:网络 导读:php生成随机密码的函数实例,php生成随机密码的函数,生成数字.大小写字母与特殊字符组合的随机密码. ...
- php header函数下载文件实现代码
在php中header函数的使用很大,header不但可以向客户端发送原始的 HTTP 报头信息,同时还可以直接实现文件下载操作 header函数最常用的不是用于下载而是用于发送http类的 跳转 它 ...
- PHP header() 函数详细说明(301、404等错误设置)
原文来自:http://www.veryhuo.com/a/view/41466.html 如果您刚刚开始学习PHP,可能有许多函数需要研究,今天我们就来学习一下PHP Header()的使用方法,更 ...
- php header函数要点
发布:snowfly 来源:网络 [大 中 小] 相信很多人写程序时,使用 header(location) 进行跳转往往不记得写 exit() 语句,这种做法存在严重风险. 从浏览器来看 ...
- 微信小程序实例代码
http://blog.csdn.net/zuoliangzhu/article/details/53862576#t1 项目结构 └─ empty-folder/ ················· ...
- Php header()函数及其常见使用
语法: Void header(string $string[,bool $replace=true [, int $http_response_code) 向客户端发送原始的HTTP报头 需注意: ...
- PHP中的header()函数作用
PHP 中 header()函数的作用是给客户端发送头信息. 什么是头信息?这里只作简单解释,详细的自己看http协议.在 HTTP协议中,服务器端的回答(response)内容包括两部分:头信息(h ...
随机推荐
- IOS开发 xcode报错之has been modified since the precompiled header was built
转载的文章 很实用 IOS开发xcode报错之has been modified since the precompiled header was built 今天做百度地图的时候第一次发现下面错误 ...
- 转js contains 方法
function Jcontains(root, el) { if (root.compareDocumentPosition) return root === el || !!(root.compa ...
- Android使用MVP时应该注意的问题
生命周期:因为Presenter是View创建的,我们需要确保完全地理解View的生命周期,特别是因为它将最有可能去处理状态更新和异步数据.举个例子,每一个Presenter应该在View destr ...
- Android学习笔记⑦——UI组件的学习AdapterView相关1
AdapterView是一个非常重要的组件之一,他非常灵活,所以得好好学...AdapterView本身是一个抽象类,派生出来的子类用法也十分相似,只是界面有一定的区别,因此本节把他们归为一类 Ada ...
- 使用app loader上传iOS应用
正如上篇文章中提到的,因为一些原因我尝试通过app loader打包上传应用到appStore 其实这个使用还是挺简单 的 首先要知道怎么打开loader 打开方式有两种 一种是直接打开loade ...
- Amazon全场满$35减$5 (需Facebook)
在Amazon.com上建一个Wish List(创建Wish List后须点击“Manage your lists”,在“Privacy”那一栏选择“Public”或“Shared”,再回到这个链接 ...
- asp.net在word页眉插入条形码
条形码控件需要引用MSBCODE9.OCX组件.该组件的默认位置是C:\Program Files\Microsoft Office\Office12\2052\MSBCODE9.OCX using ...
- Rolls.java (page44)
对象的数组:模拟T次投掷骰子的Counter对象的用例: Rolls.java 如下:所用类列表:Counter, StdOut, StdRandom 见page42 public class Rol ...
- React Native中常见操作
一.如何将项目安装到iOS手机上? 1.将手机于电脑连接好,并将Xcode打开连接上手机 2.在General -> Team 下添加自己的Apple ID. 3.改本地的IP地址: 4.点击 ...
- codeforces 590C C. Three States(bfs+连通块之间的最短距离)
题目链接: C. Three States time limit per test 5 seconds memory limit per test 512 megabytes input standa ...