您好,欢迎访问一九零五行业门户网

PHP之header函数详解

通过的用法如设置编码、发送http状态值以及重定向。
php header utf8 :
header(“content-type: text/html; charset=utf-8″);
php header 404 :
header(“http/1.0 404 not found”);
上述两个例子分别是设置utf8编码和发送404状态。
header重定向:
header(‘location: http://www.phpthinking.com’);
其他常用的header用法:
// header永久性重定向,一般301与header location一起使用.header(‘http/1.1 301 moved permanently’);header(‘location: http://www.phpthinking.com/’);// header延时刷新页面//与html页面中的效果一样header(‘refresh: 10; url=http://www.phpthinking.com/’);// header设置页面语言header(‘content-language: en’);// 对于下载页面,可以声明文件类型和文件名header(‘content-type: application/octet-stream’);header(‘content-disposition: attachment; filename=”filename.zip”‘);header(‘content-transfer-encoding: binary’);// header设置缓存和缓存过期时间header(‘cache-control: no-cache, no-store, max-age=0, must-revalidate’);header(‘expires: mon, 26 jul 1997 05:00:00 gmt’);// header设置页面编码:header(‘content-type: text/html; charset=utf-8′);
其它类似信息

推荐信息