PHP HTTP header using the header function to set an example method


// ok
header('HTTP/1.1 200 OK');

// Sets a 404 header  :
header('HTTP/1.1 404 Not Found');

// Set address is permanently redirect
header('HTTP/1.1 301 Moved Permanently');

// Go to a new address

// File delay Steering  :
header('Refresh: 10; url=');
print 'You will be redirected in 10 seconds';

// Of course, you can also use  html Syntax implementation
// <meta http-equiv="refresh" content="10; />

// override X-Powered-By: PHP:
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b');

// Document language
header('Content-language: en');

// Tells the browser to the last modification time
$time = time() - 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');

// Tells the browser to document content has not changed
header('HTTP/1.1 304 Not Modified');

// Sets the content length
header('Content-Length: 1234');

// Set to a download type
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=""');
header('Content-Transfer-Encoding: binary');
// load the file to send:

//  Disable the cache for 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 past
header('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 format
header('Content-Type: image/jpeg'); //JPG***
header('Content-Type: application/zip'); // ZIP File
header('Content-Type: application/pdf'); // PDF File
header('Content-Type: audio/mpeg'); //  Audio file
header('Content-Type: application/x-shockw**e-flash'); //Flash Animation  

// Displays a login dialog 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 时间:2010-02-24 人气:355
blog comments powered by Disqus


  • script标签属性用type还是language 2013-11-10

    本文介绍了javascript脚本中标签属性type与language的区别分析,有需要的小伙伴可以参考下 被人问起一个问题: <script language = "JavaScript"> <script type="text/javascript"> <script> 这三个标签的使用有什么区别? 虽然一直在用,却也没有好好去弄清楚,这里详细说明一下. 查阅一些资料,主要是浏览器支持问题.type 和 language 属性

  • script标签属性type与language使用选择 2015-04-25

    很多使用javascript的朋友都有着这样一个问题:script标签属性type与language使用应如何选择,为解决此疑惑,本文详细整理了一下,需要的朋友可以参考下 被人问起一个问题: <script language = "JavaScript"> <script type="text/javascript"> <script> 这三个标签的使用有什么区别? 虽然一直在用,却也没有好好去弄清楚,这里详细说明一下. 查阅一些

  • oracle numeric functions, character functions, date functions, conversion functions, to_char, automatic type conversion, date, type conversion 2011-09-28

    Numeric function abs: absolute value function, such as: abs (-5) 5 sqrt: square root functions, such as: sqrt (2) 1.41421356 power: the exponentiation function, such as: power (2,3) 8 cos: Cosine trigonometric functions, such as: cos (3.14159) -1 mod

  • JS type conversion and type of judge 2010-07-11

    In Java, the basic type among the cast is not so, for example, convert an integer to a string, you must use Integer.toString () static method or String.valueOf () static method to convert a string to an integer, must use Integer.valueOf (). Can be se

  • Answer: SQL interview questions: get the highest score of each type, the highest number of units of a certain type, a second type of unit! 2010-12-26

    Recently saw a SQL interview questions, think you can familiarize yourself as an example, although This question is not difficult, but to see what we have discussed about the function to deal with, I think the problem becomes complicated, and should

  • java data type, hibernate data type, sql type of data standards for correspondence tables between 2009-08-22

    Java data type Hibernate Data Type Standard SQL data types (PS: for different DB may vary) byte, java.lang.Byte byte TINYINT short, java.lang.Short short SMALLINT int, java.lang.Integer integer INGEGER long, java.lang.Long long BIGINT float, java.lan

  • input type = "image" input type = "submit" difference 2011-01-09

    input type = "image" input type = "submit" difference input type = "submit" button on the form is submitted, using the system default style, input type = "image" can also submit the form, but the use of user-specifi

  • Use% TYPE and% ROWTYPE type of variable 2011-05-20

    Use% TYPE and% ROWTYPE type of variable The definition of variables can be used when dealing with the provisions of oracle data types, you can also use the% TYPE and% ROWTYPE to define variables. % TYPE is designed for the type of variable is stored

  • There is no result type defined for type 'json'... 2012-06-21

    struts2的json plugin可以实现struts2和json的完美结合,struts2的官方文档: 刚刚整合struts2和json出现了个小问题There is no result type defined for type 'json', 在struts.xml中有如下action定义 <action name="menu" class="com.l

  • struts2整合json出现no result type defined for type 'json'的解决方法 2013-12-12

    struts2的json plugin可以实现struts2和json的完美结合,由于本篇主要是介绍整合过程中遇到的问题,所以编程实现的方法这里就不重复了,具体可以参看struts2的官方文档: 我在struts.xml中有如下action定义: <action name="product_group" class="customers.products&quo

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.383 (s). 12 q(s)