程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> PHP header()函數常用方法

PHP header()函數常用方法

編輯:關於PHP編程

//定義編碼

//Atom

//CSS

//Javascript

//JPEG Image

//JSON

//PDF

//RSS

//Text (Plain)

//XML

// ok

//設置一個404頭:

//設置地址被永久的重定向

//轉到一個新地址

//文件延遲轉向:
print 'You will be redirected in 10 seconds';
//當然,也可以使用html語法實現
// <meta http-equiv="refresh" content="10;http://www.jbxue.com/ />
// override X-Powered-By: PHP:
header('X-Powered-By: Brain/0.6b');
//文檔語言

//告訴浏覽器最後一次修改時間
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
//告訴浏覽器文檔內容沒有發生改變

//設置內容長度

//設置為一個下載類型
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile('example.zip');
// 對當前文檔禁用緩存
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
//設置內容類型:
header('Content-Type: text/html; charset=utf-8');
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-shockw**e-flash'); //Flash動畫
//顯示登陸對話框
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved