php header函数用法示例
内容摘要
这篇文章主要为大家详细介绍了php header函数用法示例,具有一定的参考价值,可以用来参考一下。
本代码演示了php中header函数的详细用法,php修改http header演示,对此感兴趣的
本代码演示了php中header函数的详细用法,php修改http header演示,对此感兴趣的
文章正文
这篇文章主要为大家详细介绍了php header函数用法示例,具有一定的参考价值,可以用来参考一下。
本代码演示了php中header函数的详细用法,php修改http header演示,对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | <code class = "php" > /** * header函数的用法 * * @param * @arrange (www.idcnote.com) **/ //查看相关链接以获取更多状态代码 //使用此标头指令修复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' ; /*** 来自php教程(www.idcnote.com) ***/ </code> |
注:关于php header函数用法示例的内容就先介绍到这里,更多相关文章的可以留意
代码注释