常用实例
1实现页面的重定向( 状态码302)
<?php
header("Location:http://www.baidu.com");
exit();
?>
2 页面不存在 (404页面)
<?php
header("HTTP/1.1 404 Not Found");
header("status:404 Not Found");
?>
3下载页面 的应用
<?php
header("Content-type:application/octem-stream");
header('Content-Disposition:attachment;filename"example.zip"');
header('Content-Transfer-Encoding: binary')
?>
4设置文件的类型
<?php
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');