---
title: "php中的header汇总"
author: "javaeyeren"
date: "2009-02-02T01:32:00Z"
tags: []
slug: "php-header"
draft: false
lastmod: "2009-02-02T01:32:00Z"
id: 601361
url: "https://javaeyeren.iteye.com/blog/601361"
---

Content-Type: xxxx/yyyy  
Location: xxxx:yyyy/zzzz  
Status: nnn xxxxxx  
在新的多型标头规格 (Multipart MIME) 方可以出现二次以上。

使用范例  
范例一: 本例使浏览器重定向到 [**PHP**](http://writeblog.csdn.net/) 的官方网站。  
&lt;?php  
Header("Location: [http://www.php.net](http://www.php.net/)";);  
exit;  
?&gt;  
范例二: 要使用者每次都能得到最新的资料，而不是 Proxy 或 cache 中的资料，可以使用下列的标头  
&lt;?php  
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");  
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");  
header("Cache-Control: no-cache, must-revalidate");  
header("Pragma: no-cache");  
?&gt;  
范例三: 让使用者的浏览器出现找不到档案的信息。  
&lt;?php  
header("Status: 404 Not Found");  
?&gt;  
范例四:让使用者下载档案。&lt;?php  
header("Content-type: application/x-gzip");  
header("Content-Disposition: attachment; filename=文件名");  
header("Content-Descrīption: PHP3 Generated Data");  
?&gt;