范例一:用于页面跳转
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-description: php3 generated da
注意:在header函数前不能有任何输出语句!就是说在这些函数的前面不能有任何文字、空行、回车等,而且最好在header()函数后加上exit()函数