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), etc header('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 past header('Pragma: no-cache');
登录后复制
相关推荐:php培训
以上就是php header函数怎么设置HTTP头的详细内容,更多请关注Work网其它相关文章!