The header in PHP is divided into three parts:
The first part: The version of the HTTP Protocol (http-version);
The second part: status code;
The third part: The reason phrase (reason-phrase).
Example code:
Return page HTTP information with the header command
1, the request page normal return
Header (' http/1.1 OK ');
2. Page Not found
Header (' http/1.1 404 Not Found ');
3, 301 Permanent Turn
Header (' http/1.1 301 Moved permanently ');
4. Restricted access
Header (' http/1.1 403 Forbidden ');
5. Server Error
Header (' http/1.1 Internal Server Error ');
6. Redirect to a new address
Header (' location:http://www.abcd9.com/');
Redirect after a period of delay
Header (' refresh:10; url=http://www.abcd9.com/'); 10 seconds delay
Overwrite x-powered-by value
Header (' x-powered-by:php/4.4.0 ');
Header (' x-powered-by:brain/0.6b ');
content language (en = 中文版)
Header (' content-language:en ');
Last modified time (can be used when caching)
$time = time () –60; or Filemtime ($FN), etc
Header (' last-modified: '. Gmdate (' d, D M Y h:i:s ', $time). ' GMT ');
tell the browser what to get is not updated
Header (' http/1.1 304 not Modified ');
set the length of the content (can be used when caching)
Header (' content-length:1234 ');
used to identify the download file
Header (' Content-type:application/octet-stream ');
Header (' content-disposition:attachment; filename= ' Abcd9.zip ');
Header (' content-transfer-encoding:binary ');
Disable caching of the current document
Header (' Cache-control:no-cache, No-store, max-age=0, Must-revalidate ');
Header (' Expires:mon, Jul 1997 05:00:00 GMT ');
Set Content Type
Header (' content-type:text/html; Charset=utf-8 '); Encoded as Utf-8
Header (' Content-type:text/plain '); Plain text files
Header (' Content-type:image/jpeg '); JPG pictures
Header (' Content-type:application/zip '); ZIP Archive Package File
Header (' content-type:application/pdf '); PDF ebook File
Header (' Content-type:audio/mpeg '); MPEG (MP3,...) Audio files
Header (' Content-type:application/x-shockwave-flash '); Flash file
Displays the Login dialog box, which can be used for HTTP authentication
Header (' http/1.1 401 Unauthorized ');
Header (' Www-authenticate:basic realm= ' Top Secret ');
print ' Text that would be displayed if the user hits cancel or ';
print ' enters wrong login data ';
PHP Header Common instructions explained