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 人气:378
blog comments powered by Disqus


  • 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

  • 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> 这三个标签的使用有什么区别? 虽然一直在用,却也没有好好去弄清楚,这里详细说明一下. 查阅一些

  • 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

  • Tomcat Web application using web.xml control Xiangjie (1) 2010-07-30

    Transfer from: Tomcat Web application using web.xml control Xiangjie (1) Study: feng_sundy Source: unknown (2006-04-29 13:39:34) A definition of the head and the root element Deployment desc

  • Tomcat Web application using web.xml control Xiangjie (2) 2010-07-30

    Tomcat Web application using web.xml control Xiangjie (2) Study: feng_sundy Source: unknown (2006-04-29 13:42:24) 7 specified welcome page If the user provides a http://host/webAppPrefix/directoryName/ such as a directory name that contains the file

  • 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

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.032 (s). 11 q(s)