经测试代码如下:
/**
* header函数的用法
*
* @param
* @arrange (512.笔记) jb51.cc
**/
//查看相关链接以获取更多状态代码
//使用此标头指令修复404标头
//由url重写生成...
header('HTTP/1.1 200 OK');
//找不到页面:
header('HTTP/1.1 404 Not Found');
//访问被禁止:
header('HTTP/1.1 403 Forbidden');
//永久移动的页面应该用于
//所有重新编辑,因为搜索引擎知道
//发生了什么,可以轻松更新他们的网址。
header('HTTP/1.1 301 Moved Permanently');
// 服务器错误
header('HTTP/1.1 500 Internal Server Error');
//重定向到新位置:
header('Location: http://www.example.org/');
//延迟重定向:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';
//您也可以使用HTML语法:
// <Meta http-equiv="refresh" content="10;http://www.example.org/ />
//覆盖X-Powered-By值
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b');
//内容语言(en =英语)
header('Content-language: en');
//最后修改(适合缓存)
$time = time() - 60; // or filemtime($fn),etc
header('Last-Modified: '.gmdate('D,d M Y H:i:s',$time).' GMT');
//标题用于告诉浏览器该内容
//没有改变
header('HTTP/1.1 304 Not Modified');
//设置内容长度(适合缓存):
header('Content-Length: 1234');
//下载标题:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
//加载要发送的文件:
readfile('example.zip');
//禁用当前文档的缓存:
header('Cache-Control: no-cache,no-store,max-age=0,must-revalidate');
header('Expires: Mon,26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
//设置内容类型:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); // plain text file
header('Content-Type: image/jpeg'); // JPG picture
header('Content-Type: application/zip'); // ZIP file
header('Content-Type: application/pdf'); // PDF file
header('Content-Type: audio/mpeg'); // Audio MPEG (MP3,...) file
header('Content-Type: application/x-shockwave-flash'); // Flash animation
//显示登录框
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';
/*** 来自编程之家 jb51.cc(jb51.cc) ***/