header()函數的作用是:發送一個原始 HTTP 標頭[Http Header]到客戶端。標頭 (header) 是服務器以 HTTP 協義傳 HTML 資料到瀏覽器前所送出的字串,在標頭與 HTML 文件之間尚需空一行分隔。在 php中送回 HTML 資料前,需先傳完所有的標頭。
常用header匯總:
header('Content-Type: text/html; charset=utf-8'); //網頁編碼
header('Content-Type: text/plain'); //純文本格式
header('Content-Type: image/jpeg'); //JPG、JPEG
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音頻文件
header('Content-type: text/css'); //css文件
header('Content-type: text/javascript'); //js文件
header('Content-type: application/json'); //json
header('Content-type: application/pdf'); //pdf
header('Content-type: text/xml'); //xml
header('Content-Type: application/x-shockw**e-flash'); //Flash動畫