1.實(shí)現(xiàn)重定向(狀態(tài)碼302)
<?php
header(”Location: http://www.baidu.com”);
exit;
2.刷新頁面
header("refresh:2;url=http://www.baidu.com");
3.頁面不存在(404頁面)
<?php
header('HTTP/1.1 404 Not Found');
header("status: 404 Not Found");
4.永久重定向(狀態(tài)碼301)
<?
Header( "HTTP/1.1 301 Moved Permanently" ) ;
Header( "Location: www.baidu.com" );
5.下載文件
//返回的文件
header("Content-type: application/octet-stream");
//按照字節(jié)大小返回
header("Accept-Ranges: bytes");
//返回文件大小
header("Accept-Length: $file_size");
//這里客戶端的彈出對(duì)話框,對(duì)應(yīng)的文件名
header("Content-Disposition: attachment; filename=".$file_name);
6.文檔語言
<?
header('Content-language: en');
7.設(shè)置文檔類型
header('Content-Type: text/html; charset=utf-8');//utf-8格式html
header('Content-Type: text/plain'); //純文本格式
header('Content-Type: image/jpeg'); //JPG圖片
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音頻文件
header('Content-Type: application/x-shockwave-flash'); //Flash動(dòng)畫
8.設(shè)置文檔長(zhǎng)度
<?
header('Content-Length: 1024');
9.禁用緩存
<拭卿?
header("Cache-Control:no-cache,must-revalidate,no-store");
header("Pragma:no-cache");
header("Expires:-1");
header ( " Last-Modified:" . gmdate ( " D, d M Y H:i:s " ). "GMT " );