1. 程式人生 > >header("Content-type:text/html;charset=utf-8");

header("Content-type:text/html;charset=utf-8");

 

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動畫