首页  >  文章  >  php教程  >  PHP header 的几种用法

PHP header 的几种用法

WBOY
WBOY原创
2016-06-16 08:41:151012浏览

PHP header 的几种用法,你知道几种?
1. 跳转页面header('Location:'.$url);  //Location和":"之间无空格。2. 声明content-typeheader('content-type:text/html;charset=utf-8');3. 返回response状态码header('HTTP/1.1 404 Not Found');4. 在某个时间后执行跳转header('Refresh: 10; url=http://www.baidu.com/');  //10s后跳转。5. 控制浏览器缓存header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");<br> header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");<br> header("Cache-Control: no-cache, must-revalidate");<br> header("Pragma: no-cache");6. 执行http验证header('HTTP/1.1 401 Unauthorized');<br> header('WWW-Authenticate: Basic realm="Top Secret"');7. 执行下载操作header('Content-Type: application/octet-stream'); //设置内容类型<br> header('Content-Disposition: attachment; filename="example.zip"'); //设置MIME用户作为附件<br> header('Content-Transfer-Encoding: binary'); //设置传输方式<br> header('Content-Length: '.filesize('example.zip')); //设置内容长度更多【干货分享】,请关注一位有情怀的工程师。
PHP header 的几种用法

AD:真正免费,域名+虚机+企业邮箱=0元

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn