php header函数设置http头的示例如下:
(视频教程推荐:java视频教程)
定义编码
header( 'content-type:text/html;charset=utf-8 ');
设置一个404头:
header('http/1.1 404 not found');
设置地址被永久的重定向
header('http/1.1 301 moved permanently');
转到一个新地址
header('location: http://www.example.org/');
文件延迟转向:
header('refresh: 10; url=http://www.example.org/');print 'you will be redirected in 10 seconds';
告诉浏览器最后一次修改时间
$time = time() - 60; // or filemtime($fn), etcheader('last-modified: '.gmdate('d, d m y h:i:s', $time).' gmt');
对当前文档禁用缓存
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 pastheader('pragma: no-cache');
相关推荐:php培训
以上就是php header函数怎么设置http头的详细内容。
