Home > php教程 > php手册 > body text

php中的header汇总

WBOY
Release: 2016-06-06 19:54:53
Original
874 people have browsed it

Content-Type: xxxx/yyyy Location: xxxx:yyyy/zzzz Status: nnn xxxxxx 在新的多型标头规格 (Multipart MIME) 方可以出现二次以上。 使用范例 范例一: 本例使浏览器重定向到 PHP 的官方网站。 ?php Header(Location: http://www.php.net ;); exit; ? 范例二

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

使用范例
范例一: 本例使浏览器重定向到 PHP 的官方网站。
Header("Location: http://www.php.net";);
exit;
?>
范例二: 要使用者每次都能得到最新的资料,而不是 Proxy 或 cache 中的资料,可以使用下列的标头
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");
?>
范例三: 让使用者的浏览器出现找不到档案的信息。
header("Status: 404 Not Found");
?>
范例四:让使用者下载档案。header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=文件名");
header("Content-Descrīption: PHP3 Generated Data");
?>


 
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!