当前位置: 首页 > 后端技术 > PHP

PHPheader()函数常用方法

时间:2023-03-30 02:08:22 PHP

PHP常用方法header()函数定义编码header('Content-Type:text/html;charset=utf-8');Atomheader('Content-type:application/atom+xml');CSHeader('Content-type:text/css');Javascriptheader('Content-type:text/javascript');JPEGImageheader('Content-type:image/jpeg');JSONheader('Content-type:application/json');PDFheader('Content-type:application/pdf');RSSheader('Content-Type:application/rss+xml;charset=ISO-8859-1');Text(Plain)header('Content-type:text/plain');XMLheader('内容类型:文本/xml');okheader('HTTP/1.1200OK');设置404标头:header('HTTP/1.1404NotFound');将地址设置为永久重定向header('HTTP/1.1301MovedPermanently');去一个新的地址header('Location:http://www.jbxue.com/');文档语言标题('Content-language:en');告诉浏览器最后一次修改时间$time=time()-60;//或者filemtime($fn),etcheader('Last-Modified:'.gmdate('D,dMYH:i:s',$time).'GMT');告诉浏览器文档内容没有改变header('HTTP/1.1304NotModified');设置内容长度header('Content-Length:1234');将其设置为下载类型标头('Content-Type:application/octet-stream');header('Content-Disposition:attachment;filename="example.zip"');header('Content-Transfer-Encoding:binary');//加载文件发送:readfile('example.zip');对当前文档禁止使用存储header('Cache-Control:no-cache,no-store,max-age=0,must-revalidate');header('Expires:Mon,26Jul199705:00:00格林威治标准时间');//Pastheader中的日期('Pragma:no-cache');