Home > php教程 > php手册 > PHP header 的几种用法

PHP header 的几种用法

WBOY
Release: 2016-06-16 08:41:15
Original
1069 people have browsed it

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元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template