时时商务社区
标题:
php header功能的使用
[打印本页]
作者:
新格网络
时间:
2018-2-14 08:11
header() 函数向客户端发送原始的 HTTP 报头。
[U]复制代码[/U] 代码如下:
相同)
header('Refresh: 3; url=http://www.jb51.net/');
echo '10后跳转到http://www.jb51.net';
// 重写 X-Powered-By 值
header('X-Powered-By: PHP/5.3.0');
header('X-Powered-By: Brain/0.6b');
//设置上下文语言
header('Content-language: en');
// 设置页面最后修改时间(多用于防缓存)
$time = time() - 60; //建议使用filetime函数来设置页面缓存时间
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
// 设置内容长度
header('Content-Length: 39344');
// 设置头文件类型,可以用于流文件或者文件下载
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');
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');
header('Content-Type: image/jpeg');
header('Content-Type: application/zip');
header('Content-Type: application/pdf');
header('Content-Type: audio/mpeg');
header('Content-Type: application/x-shockwave-flash');
//.... 至于Content-Type 的值 可以去查查 w3c 的文档库,那里很丰富
?>
您可能感兴趣的文章:
php出现Cannot modify header information问题的解决方法大全
php header()函数使用说明
PHP Header用于页面跳转要注意的几个问题总结
php利用header函数实现文件下载时直接提示保存
php session_start()关于Cannot send session cache limiter - headers already sent错误解决方法
PHP 页面编码声明方法详解(header或meta)
PHP下利用header()函数设置浏览器缓存的代码
php header Content-Type类型小结
PHP header()函数使用详细(301、404等错误设置)
php中get_headers函数的作用及用法的详细介绍
探讨php中header的用法详解
PHP 使用header函数设置HTTP头的示例解析 表头
浅析php header 跳转
php用header函数实现301跳转代码实例
PHP错误Warning: Cannot modify header information - headers already sent by解决方法
PHP使用header()输出图片缓存实例
PHP 常用的header头部定义汇总
欢迎光临 时时商务社区 (http://bbs.4435.cn/)
Powered by Discuz! X3.2