长乐王
长乐王

PHP的header()函数常用content-type汇总

//HTML
header('Content-Type:text/html;charset=utf-8');
//CSS
header('Content-type:text/css;charset=utf-8');
//Javascript
header('Content-type:text/javascript;charset=utf-8');
//XML
header('Content-type:application/xml;charset=utf-8');
//JSON
header('Content-type:application/json;charset=utf-8');

//JPEGImage
header('Content-type:image/jpeg');
//PDF
header('Content-type:application/pdf');
//RSS
header('Content-Type:application/rss+xml;charset=ISO-8859-1');

//ok
header('HTTP/1.1 200 OK');
//设置一个404头:
header('HTTP/1.1 404 Not Found');
//设置地址被永久的重定向
header('HTTP/1.1 301 Moved Permanently');

//转到一个新地址
header('Location:http://www.hulumiao.cn/');
//延迟跳转到新地址
header('Refresh:10;url=http://www.hulumiao.cn/');
本文番号: 长乐王 - 前端开发 - PHP的header()函数常用content-type汇总

评论